1 3
from mopidy import listener
2

3

4 3
class AudioListener(listener.Listener):
5

6
    """
7
    Marker interface for recipients of events sent by the audio 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 audio listener events"""
19 3
        listener.send(AudioListener, event, **kwargs)
20

21 3
    def reached_end_of_stream(self):
22
        """
23
        Called whenever the end of the audio stream is reached.
24

25
        *MAY* be implemented by actor.
26
        """
27 3
        pass
28

29 3
    def stream_changed(self, uri):
30
        """
31
        Called whenever the audio stream changes.
32

33
        *MAY* be implemented by actor.
34

35
        :param string uri: URI the stream has started playing.
36
        """
37 3
        pass
38

39 3
    def position_changed(self, position):
40
        """
41
        Called whenever the position of the stream changes.
42

43
        *MAY* be implemented by actor.
44

45
        :param int position: Position in milliseconds.
46
        """
47 3
        pass
48

49 3
    def state_changed(self, old_state, new_state, target_state):
50
        """
51
        Called after the playback state have changed.
52

53
        Will be called for both immediate and async state changes in GStreamer.
54

55
        Target state is used to when we should be in the target state, but
56
        temporarily need to switch to an other state. A typical example of this
57
        is buffering. When this happens an event with
58
        `old=PLAYING, new=PAUSED, target=PLAYING` will be emitted. Once we have
59
        caught up a `old=PAUSED, new=PLAYING, target=None` event will be
60
        be generated.
61

62
        Regular state changes will not have target state set as they are final
63
        states which should be stable.
64

65
        *MAY* be implemented by actor.
66

67
        :param old_state: the state before the change
68
        :type old_state: string from :class:`mopidy.core.PlaybackState` field
69
        :param new_state: the state after the change
70
        :type new_state: A :class:`mopidy.core.PlaybackState` field
71
        :type new_state: string from :class:`mopidy.core.PlaybackState` field
72
        :param target_state: the intended state
73
        :type target_state: string from :class:`mopidy.core.PlaybackState`
74
            field or :class:`None` if this is a final state.
75
        """
76 3
        pass
77

78 3
    def tags_changed(self, tags):
79
        """
80
        Called whenever the current audio stream's tags change.
81

82
        This event signals that some track metadata has been updated. This can
83
        be metadata such as artists, titles, organization, or details about the
84
        actual audio such as bit-rates, numbers of channels etc.
85

86
        For the available tag keys please refer to GStreamer documentation for
87
        tags.
88

89
        *MAY* be implemented by actor.
90

91
        :param tags: The tags that have just been updated.
92
        :type tags: :class:`set` of strings
93
        """
94 3
        pass

Read our documentation on viewing source code .

Loading