Create helper for sending events to BackendListeners
This commit is contained in:
parent
0ccb5dec23
commit
e919dcf627
@ -464,27 +464,17 @@ class PlaybackController(object):
|
||||
logger.debug(u'Triggering started playing event')
|
||||
if self.current_track is None:
|
||||
return
|
||||
ActorRegistry.broadcast({
|
||||
'command': 'pykka_call',
|
||||
'attr_path': ('started_playing',),
|
||||
'args': [],
|
||||
'kwargs': {'track': self.current_track},
|
||||
}, target_class=BackendListener)
|
||||
BackendListener.send('started_playing',
|
||||
track=self.current_track)
|
||||
|
||||
def _trigger_stopped_playing_event(self):
|
||||
# TODO Test that this is called on next/prev/end-of-track
|
||||
logger.debug(u'Triggering stopped playing event')
|
||||
if self.current_track is None:
|
||||
return
|
||||
ActorRegistry.broadcast({
|
||||
'command': 'pykka_call',
|
||||
'attr_path': ('stopped_playing',),
|
||||
'args': [],
|
||||
'kwargs': {
|
||||
'track': self.current_track,
|
||||
'time_position': self.time_position,
|
||||
},
|
||||
}, target_class=BackendListener)
|
||||
BackendListener.send('stopped_playing',
|
||||
track=self.current_track,
|
||||
time_position=self.time_position)
|
||||
|
||||
|
||||
class BasePlaybackProvider(object):
|
||||
|
||||
@ -67,7 +67,7 @@ class MpdSession(network.LineProtocol):
|
||||
|
||||
logger.debug(u'Response to [%s]:%s from %s: %s', self.host, self.port,
|
||||
self.actor_urn, log.indent(self.terminator.join(response)))
|
||||
|
||||
|
||||
self.send_lines(response)
|
||||
|
||||
def close(self):
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
from pykka import registry
|
||||
|
||||
class BackendListener(object):
|
||||
"""
|
||||
Marker interface for recipients of events sent by the backend.
|
||||
@ -9,6 +11,16 @@ class BackendListener(object):
|
||||
interested in all events.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def send(event, **kwargs):
|
||||
"""Helper to allow calling of backend listener events"""
|
||||
registry.ActorRegistry.broadcast({
|
||||
'command': 'pykka_call',
|
||||
'attr_path': (event,),
|
||||
'args': [],
|
||||
'kwargs': kwargs
|
||||
}, target_class=BackendListener)
|
||||
|
||||
def started_playing(self, track):
|
||||
"""
|
||||
Called whenever a new track starts playing.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user