Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: windows SystemMediaTransportControls integration #755

Merged
merged 55 commits into from
Jan 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
5657126
set upper version for batteries
cosven Jan 7, 2024
083c324
[ci skip] also include *.mo and *.po
mokurin000 Jan 8, 2024
fb70b7a
Update hook-feeluown.py
mokurin000 Jan 8, 2024
70d09ad
switch to aionowplaying master branch
mokurin000 Jan 8, 2024
b1eff8a
fix informed url
mokurin000 Jan 8, 2024
2b5bc0c
fix use https protocol
mokurin000 Jan 8, 2024
6424ae9
fix py3.12 support
mokurin000 Jan 8, 2024
7180a8f
fix: windows SMTC integration
mokurin000 Jan 9, 2024
70dd71b
fix `fuo_ytmusic` disturbution (#1)
mokurin000 Jan 9, 2024
69fee84
plugin: support 3.8-3.12~
mokurin000 Jan 9, 2024
0c5e91c
nowplaying: remove debug print
mokurin000 Jan 9, 2024
11452f4
nowplaying: chore: function rename
mokurin000 Jan 9, 2024
8f0124c
fix ill-formed git branch url
mokurin000 Jan 9, 2024
70336f5
fix pylint & flake8
mokurin000 Jan 9, 2024
3ec1cb9
distribution: fix #748 (#749)
mokurin000 Jan 9, 2024
3608599
feat: set id_ for windows nowplaying
mokurin000 Jan 10, 2024
9f296e1
packaging(win): append details to windows packaged executable
mokurin000 Jan 11, 2024
91fcb7c
fix(ci): install `pyinstaller-versionfile`
mokurin000 Jan 11, 2024
0d7140a
Merge branch 'branch-3.8.x' into dev-3.8.x
mokurin000 Jan 11, 2024
ffbea0b
*: introduce webserver (optional, experimental) (#736)
cosven Nov 8, 2023
e3acd31
docs: update Arch Linux package URL in quickstart.rst (#738)
felixonmars Nov 21, 2023
9e9d2a6
serializer: add type info in serialized result and json-rpc (#737)
cosven Nov 21, 2023
06a4e5e
player: some improvements about the player (#739)
cosven Dec 10, 2023
ad2cea1
gui: introduce UISupportsDiscovery protocol (#740)
cosven Dec 19, 2023
0336a56
gui: redesign ImgListView and rename some modules (#741)
cosven Dec 29, 2023
e8d16ee
gui: add recommendation page (#742)
cosven Jan 3, 2024
f255e30
player: try to find standby when there is unknown expcetion (#743)
cosven Jan 6, 2024
c82e6ed
gui: add fav page (#744)
cosven Jan 6, 2024
d38a67f
gui: introduce UISupportsLoginEvent protocol (#745)
cosven Jan 6, 2024
dafcacb
*: remove model v1 (#746)
cosven Jan 10, 2024
0fa4c7b
bump version to v4.0a0 (#753)
cosven Jan 10, 2024
b47a5a4
Merge branch 'feeluown:master' into dev-3.8.x
mokurin000 Jan 11, 2024
94c9f8c
fix(ci): apply version conversion
mokurin000 Jan 11, 2024
bcee3ef
fix(ci): install `pyinstaller-versionfile`
mokurin000 Jan 11, 2024
253fb7b
Merge branch 'win32-copy-version-info' into dev-4.0a0
mokurin000 Jan 11, 2024
0ed5733
Merge branch 'master' into dev-4.0a0
mokurin000 Jan 11, 2024
a4389d6
feat: implement `nowplaying.on_stop`
mokurin000 Jan 11, 2024
333ab82
Merge branch 'master' into dev-4.0a0
mokurin000 Jan 12, 2024
c552e39
ci: version_file is generated in Makefile
mokurin000 Jan 12, 2024
2475715
feat: set playprop.Rate
mokurin000 Jan 12, 2024
e176722
Merge branch 'feeluown:master' into dev-4.0a0
mokurin000 Jan 13, 2024
cb28fdd
Merge branch 'feeluown:master' into dev-4.0a0
mokurin000 Jan 14, 2024
6dafac9
chore: switch to brucezhang/anp
mokurin000 Jan 14, 2024
a374585
Merge branch 'feeluown:master' into dev-4.0a0
mokurin000 Jan 16, 2024
46c6640
fix: rapid seek with fade in-out enabled may set volume to 0
mokurin000 Jan 16, 2024
77d11ba
chore: max_volume is unneeded
mokurin000 Jan 17, 2024
502d227
macos -> us merged in upstream
mokurin000 Jan 19, 2024
08fdef9
Merge branch 'master' into dev-4.0a0
mokurin000 Jan 19, 2024
fcb5a8e
Merge branch 'feeluown:master' into dev-4.0a0
mokurin000 Jan 20, 2024
4cdb647
merge upstream/master
mokurin000 Jan 21, 2024
33a3dfd
dep: bump aionowplaying to 0.10
mokurin000 Jan 23, 2024
b62972a
Merge branch 'master' into dev-4.0a0
mokurin000 Jan 23, 2024
e4d216b
Update feeluown/plugin.py
mokurin000 Jan 23, 2024
2fd0d06
remove dep: import-metadata
mokurin000 Jan 23, 2024
af13eb8
Merge branch 'master' into dev-4.0a0
mokurin000 Jan 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 24 additions & 11 deletions feeluown/nowplaying/nowplaying.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# pylint: disable=import-error
import logging
import os

import aionowplaying as aionp

Expand All @@ -19,19 +20,22 @@
}


def to_aionp_time(t):
return int(t * 1000)
def sec_to_us(t_sec):
return int(t_sec * 1000 * 1000)


def from_aionp_time(t):
return t / 1000
def us_to_sec(t_microsec):
return t_microsec / 1000 / 1000


class NowPlayingService(aionp.NowPlayingInterface):
def __init__(self, app: 'ServerApp'):
super().__init__('FeelUOwn')
self._app = app

if os.name == "nt":
self._app.player.position_changed.connect(self.update_position)

self._app.player.seeked.connect(self.update_position)
self._app.player.media_loaded.connect(self.on_player_media_loaded,
aioqueue=True)
Expand All @@ -53,6 +57,7 @@ def __init__(self, app: 'ServerApp'):
self.set_playback_property(PlayProp.CanGoPrevious, True)
self.set_playback_property(PlayProp.CanSeek, True)
self.set_playback_property(PlayProp.CanControl, True)
self.set_playback_property(PlayProp.Rate, 1.0)

def update_playback_mode(self, mode: PlaybackMode):
mode_mapping = {
Expand All @@ -71,14 +76,16 @@ def update_song_metadata(self, meta: dict):
metadata.album = meta.get('album', '')
metadata.title = meta.get('title', '')
metadata.cover = meta.get('artwork', '')
metadata.url = ''
metadata.url = meta.get('uri', '')
if os.name == 'nt':
metadata.id_ = meta.get('uri', '')
self.set_playback_property(PlayProp.Metadata, metadata)

def update_duration(self, duration):
self.set_playback_property(PlayProp.Duration, int(duration * 1000))
self.set_playback_property(PlayProp.Duration, int(sec_to_us(duration or 0)))

def update_position(self, position):
self.set_playback_property(PlayProp.Position, int(position * 1000))
self.set_playback_property(PlayProp.Position, int(sec_to_us(position or 0)))

def update_playback_status(self, state):
self.set_playback_property(PlayProp.PlaybackStatus,
Expand All @@ -96,6 +103,9 @@ async def on_next(self):
async def on_previous(self):
self._app.playlist.previous()

def on_stop(self):
self._app.player.stop()

def on_loop_status(self, status: aionp.LoopStatus):
if status == aionp.LoopStatus.Playlist:
self._app.playlist.playback_mode = PlaybackMode.loop
Expand All @@ -110,14 +120,17 @@ def on_shuffle(self, shuffle: bool):
else:
self._app.playlist.playback_mode = PlaybackMode.sequential

def on_seek(self, offset: int):
self._app.player.position = from_aionp_time(offset)
def on_set_position(self, track_id: str, position: int):
self._app.player.position = us_to_sec(position)

def on_seek(self, offset_us: int):
self._app.player.position = us_to_sec(offset_us)

def get_playback_property(self, name: PlayProp):
if name == PlayProp.Duration:
return to_aionp_time(self._app.player.duration)
return sec_to_us(self._app.player.duration)
elif name == PlayProp.Position:
return to_aionp_time(self._app.player.position)
return sec_to_us(self._app.player.position)
elif name == PlayProp.PlaybackStatus:
return StatePlaybackStatusMapping[self._app.player.state]
elif name == PlayProp.Rate:
Expand Down
7 changes: 6 additions & 1 deletion feeluown/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,12 @@ def _scan_entry_points(self):
"""
try:
import importlib.metadata # pylint: disable=redefined-outer-name
entry_points = importlib.metadata.entry_points().get('fuo.plugins_v1', [])
try:
entry_points = importlib.metadata.entry_points() \
.select(group='fuo.plugins_v1')
except AttributeError: # old version does not has `select` method
entry_points = importlib.metadata.entry_points() \
.get('fuo.plugins_v1', [])
except ImportError:
import pkg_resources
entry_points = pkg_resources.iter_entry_points('fuo.plugins_v1')
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@
'feeluown-bilibili>=0.3.1',
],
'macOS': [
'aionowplaying>=0.9.4,<0.10',
'aionowplaying>=0.10',
],
'win32': [
'pyshortcuts',
'aionowplaying>=0.9.4,<0.10',
'aionowplaying>=0.10',
],
'webserver': ['sanic', 'websockets', 'json-rpc'],
'webengine': ['PyQtWebEngine'],
Expand Down
Loading