1 3
from mopidy import listener
2

3

4 3
class CoreListener(listener.Listener):
5

6
    """
7
    Marker interface for recipients of events sent by the core actor.
8

9
    Any Pykka actor that mixes in this class will receive calls to the methods
10
    defined here when the corresponding events happen in the core actor. This
11
    interface is used both for looking up what actors to notify of the events,
12
    and for providing default implementations for those listeners that are not
13
    interested in all events.
14
    """
15

16 3
    @staticmethod
17 2
    def send(event, **kwargs):
18
        """Helper to allow calling of core listener events"""
19 3
        listener.send(CoreListener, event, **kwargs)
20

21 3
    def on_event(self, event, **kwargs):
22
        """
23
        Called on all events.
24

25
        *MAY* be implemented by actor. By default, this method forwards the
26
        event to the specific event methods.
27

28
        :param event: the event name
29
        :type event: string
30
        :param kwargs: any other arguments to the specific event handlers
31
        """
32
        # Just delegate to parent, entry mostly for docs.
33 3
        super().on_event(event, **kwargs)
34

35 3
    def track_playback_paused(self, tl_track, time_position):
36
        """
37
        Called whenever track playback is paused.
38

39
        *MAY* be implemented by actor.
40

41
        :param tl_track: the track that was playing when playback paused
42
        :type tl_track: :class:`mopidy.models.TlTrack`
43
        :param time_position: the time position in milliseconds
44
        :type time_position: int
45
        """
46 3
        pass
47

48 3
    def track_playback_resumed(self, tl_track, time_position):
49
        """
50
        Called whenever track playback is resumed.
51

52
        *MAY* be implemented by actor.
53

54
        :param tl_track: the track that was playing when playback resumed
55
        :type tl_track: :class:`mopidy.models.TlTrack`
56
        :param time_position: the time position in milliseconds
57
        :type time_position: int
58
        """
59 3
        pass
60

61 3
    def track_playback_started(self, tl_track):
62
        """
63
        Called whenever a new track starts playing.
64

65
        *MAY* be implemented by actor.
66

67
        :param tl_track: the track that just started playing
68
        :type tl_track: :class:`mopidy.models.TlTrack`
69
        """
70 3
        pass
71

72 3
    def track_playback_ended(self, tl_track, time_position):
73
        """
74
        Called whenever playback of a track ends.
75

76
        *MAY* be implemented by actor.
77

78
        :param tl_track: the track that was played before playback stopped
79
        :type tl_track: :class:`mopidy.models.TlTrack`
80
        :param time_position: the time position in milliseconds
81
        :type time_position: int
82
        """
83 3
        pass
84

85 3
    def playback_state_changed(self, old_state, new_state):
86
        """
87
        Called whenever playback state is changed.
88

89
        *MAY* be implemented by actor.
90

91
        :param old_state: the state before the change
92
        :type old_state: string from :class:`mopidy.core.PlaybackState` field
93
        :param new_state: the state after the change
94
        :type new_state: string from :class:`mopidy.core.PlaybackState` field
95
        """
96 3
        pass
97

98 3
    def tracklist_changed(self):
99
        """
100
        Called whenever the tracklist is changed.
101

102
        *MAY* be implemented by actor.
103
        """
104 3
        pass
105

106 3
    def playlists_loaded(self):
107
        """
108
        Called when playlists are loaded or refreshed.
109

110
        *MAY* be implemented by actor.
111
        """
112 3
        pass
113

114 3
    def playlist_changed(self, playlist):
115
        """
116
        Called whenever a playlist is changed.
117

118
        *MAY* be implemented by actor.
119

120
        :param playlist: the changed playlist
121
        :type playlist: :class:`mopidy.models.Playlist`
122
        """
123 3
        pass
124

125 3
    def playlist_deleted(self, uri):
126
        """
127
        Called whenever a playlist is deleted.
128

129
        *MAY* be implemented by actor.
130

131
        :param uri: the URI of the deleted playlist
132
        :type uri: string
133
        """
134 3
        pass
135

136 3
    def options_changed(self):
137
        """
138
        Called whenever an option is changed.
139

140
        *MAY* be implemented by actor.
141
        """
142 3
        pass
143

144 3
    def volume_changed(self, volume):
145
        """
146
        Called whenever the volume is changed.
147

148
        *MAY* be implemented by actor.
149

150
        :param volume: the new volume in the range [0..100]
151
        :type volume: int
152
        """
153 3
        pass
154

155 3
    def mute_changed(self, mute):
156
        """
157
        Called whenever the mute state is changed.
158

159
        *MAY* be implemented by actor.
160

161
        :param mute: the new mute state
162
        :type mute: boolean
163
        """
164 3
        pass
165

166 3
    def seeked(self, time_position):
167
        """
168
        Called whenever the time position changes by an unexpected amount, e.g.
169
        at seek to a new time position.
170

171
        *MAY* be implemented by actor.
172

173
        :param time_position: the position that was seeked to in milliseconds
174
        :type time_position: int
175
        """
176 3
        pass
177

178 3
    def stream_title_changed(self, title):
179
        """
180
        Called whenever the currently playing stream title changes.
181

182
        *MAY* be implemented by actor.
183

184
        :param title: the new stream title
185
        :type title: string
186
        """
187 3
        pass

Read our documentation on viewing source code .

Loading