Multi Player Support#2164
Conversation
Spotify for future3
…ext, seek, shuffle, and many more
Future3/spotify
|
For reference this PR is the base for #2116 |
pabera
left a comment
There was a problem hiding this comment.
To reduce repetition in your class MPDBackend, where you frequently update self.player_status, you could introduce a decorator that handles the status updates. This way, you won't have to manually call self.player_status.update(playing=True/False) in every method where this is needed. This also keeps your method implementations cleaner and focused on their primary responsibilities.
Decorator Definition (not sure it works directly, but should be close)
def update_player_status(playing=None):
def decorator(func):
def wrapper(self, *args, **kwargs):
result = func(self, *args, **kwargs)
if playing is not None:
self.player_status.update(playing=playing)
return result
return wrapper
return decoratorUse the Decorator in Your Class
Apply this decorator to the methods of your MPDBackend class. For methods that set the player to play, pass playing=True, and for those that pause or stop, pass playing=False. You can skip the parameter for methods that don't change the playing status.
class MPDBackend(BackendPlayer):
@plugin.tag
@update_player_status(playing=True)
def play(self):
self._active.play()
...
@plugin.tag
@update_player_status()
def toggle(self):
self._active.toggle()
# Dynamically determines playing status based on current state
current_playing = self.player_status.get_value('playing')
self.player_status.update(playing=not current_playing)
@plugin.tag
@update_player_status(playing=False)
def stop(self):
self._save_state()
self._active.stop()| self._active = None | ||
| self.player_status = None | ||
| self.status_poll_interval = 0.25 | ||
| self.status_thread = multitimer.GenericEndlessTimerClass('player.timer_status', |
There was a problem hiding this comment.
I like this! The Timer Classes are pretty well done and can be used for such use cases nicely!
| @plugin.tag | ||
| def play(self): | ||
| self._active.play() | ||
| self.player_status.update(playing=True) |
There was a problem hiding this comment.
Looks rather annoying to add self.player_status.update(playing=True/False) everywhere. You could use a decorator approach, maybe even in the BackendPlayer class (to be verified).
We already use decorators with @plugin.tag.
|
Is there any progress on this? How is it being resolved and merged? Last commit is 5 months old |
|
Currently no time to develop sorry. The problem is especially the status report to the web app so that the player can be displayed properly. Feel free to continue |
|
What is the open task? The part from above with Using decorators? Or anything else? Hardcoded a fast mopidy-spotify Version within my box with some drawbacks. Would be nice to have this instead. |
|
As already mentioned, developing a status handler which can be then used in the Web app. Additionally all Web app functionality needs to be revised. |
|
Thanks for answering first of all.. sounds like there is still much work to do?! |
|
Is the expectation here to be able to point phoniebox at a subsonic server? |
Ground work for multiple players.
Basis to solve Spotify issues or other streaming services on future3, see #1815 and #2116