Skip to content

Commit 3dcc69a

Browse files
authored
Merge pull request #42 from mopidy/mopidy-4.0.0a8
2 parents 151efa2 + 3c4b70e commit 3dcc69a

File tree

5 files changed

+31
-68
lines changed

5 files changed

+31
-68
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ classifiers = [
1414
]
1515
dynamic = ["version"]
1616
dependencies = [
17-
"mopidy >= 4.0.0a7",
17+
"mopidy >= 4.0.0a8",
1818
"pydbus >= 0.6.0",
1919
"pykka >= 4.1",
2020
]

src/mopidy_mpris/player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
import logging
77

88
from gi.repository.GLib import Variant
9-
from mopidy.core import PlaybackState
9+
from mopidy.types import PlaybackState
1010
from pydbus.generic import signal
1111

1212
from mopidy_mpris.interface import Interface

tests/dummy_audio.py

Lines changed: 27 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,23 @@
44
tests of the core and backends.
55
"""
66

7+
from typing import override
8+
79
import pykka
810
from mopidy import audio
11+
from mopidy.types import DurationMs, PlaybackState
912

1013

1114
def create_proxy(config=None, mixer=None):
1215
return DummyAudio.start(config, mixer).proxy()
1316

1417

1518
# TODO: reset position on track change?
16-
class DummyAudio(pykka.ThreadingActor):
19+
class DummyAudio(audio.Audio, pykka.ThreadingActor):
1720
def __init__(self, config=None, mixer=None):
1821
super().__init__()
19-
self.state = audio.PlaybackState.STOPPED
20-
self._volume = 0
21-
self._position = 0
22+
self.state = PlaybackState.STOPPED
23+
self._position = DurationMs(0)
2224
self._source_setup_callback = None
2325
self._about_to_finish_callback = None
2426
self._uri = None
@@ -27,72 +29,60 @@ def __init__(self, config=None, mixer=None):
2729
self._tags = {}
2830
self._bad_uris = set()
2931

30-
def set_uri(self, uri, live_stream=False, download=False): # noqa: FBT002
32+
@override
33+
def set_uri(self, uri, live_stream=False, download=False):
3134
assert self._uri is None, "prepare change not called before set"
32-
self._position = 0
35+
self._position = DurationMs(0)
3336
self._uri = uri
3437
self._stream_changed = True
3538
self._live_stream = live_stream
3639
self._tags = {}
3740

38-
def set_appsrc(self, *args, **kwargs):
39-
pass
41+
@override
42+
def set_source_setup_callback(self, callback):
43+
self._source_setup_callback = callback
4044

41-
def emit_data(self, buffer_):
42-
pass
45+
@override
46+
def set_about_to_finish_callback(self, callback):
47+
self._about_to_finish_callback = callback
4348

49+
@override
4450
def get_position(self):
4551
return self._position
4652

53+
@override
4754
def set_position(self, position):
4855
self._position = position
4956
audio.AudioListener.send("position_changed", position=position)
5057
return True
5158

59+
@override
5260
def start_playback(self):
53-
return self._change_state(audio.PlaybackState.PLAYING)
61+
return self._change_state(PlaybackState.PLAYING)
5462

63+
@override
5564
def pause_playback(self):
56-
return self._change_state(audio.PlaybackState.PAUSED)
65+
return self._change_state(PlaybackState.PAUSED)
5766

67+
@override
5868
def prepare_change(self):
5969
self._uri = None
6070
self._source_setup_callback = None
6171
return True
6272

73+
@override
6374
def stop_playback(self):
64-
return self._change_state(audio.PlaybackState.STOPPED)
65-
66-
def get_volume(self):
67-
return self._volume
68-
69-
def set_volume(self, volume):
70-
self._volume = volume
71-
return True
72-
73-
def set_metadata(self, track):
74-
pass
75+
return self._change_state(PlaybackState.STOPPED)
7576

77+
@override
7678
def get_current_tags(self):
7779
return self._tags
7880

79-
def set_source_setup_callback(self, callback):
80-
self._source_setup_callback = callback
81-
82-
def set_about_to_finish_callback(self, callback):
83-
self._about_to_finish_callback = callback
84-
85-
def enable_sync_handler(self):
86-
pass
87-
88-
def wait_for_state_change(self):
89-
pass
90-
9181
def _change_state(self, new_state):
9282
if not self._uri:
9383
return False
9484

95-
if new_state == audio.PlaybackState.STOPPED and self._uri:
85+
if new_state == PlaybackState.STOPPED and self._uri:
9686
self._stream_changed = True
9787
self._uri = None
9888

@@ -111,39 +101,12 @@ def _change_state(self, new_state):
111101
target_state=None,
112102
)
113103

114-
if new_state == audio.PlaybackState.PLAYING:
104+
if new_state == PlaybackState.PLAYING:
115105
self._tags["audio-codec"] = ["fake info..."]
116106
audio.AudioListener.send("tags_changed", tags=["audio-codec"])
117107

118108
return self._uri not in self._bad_uris
119109

120-
def trigger_fake_playback_failure(self, uri):
121-
self._bad_uris.add(uri)
122-
123110
def trigger_fake_tags_changed(self, tags):
124111
self._tags.update(tags)
125112
audio.AudioListener.send("tags_changed", tags=self._tags.keys())
126-
127-
def get_source_setup_callback(self):
128-
# This needs to be called from outside the actor or we lock up.
129-
def wrapper():
130-
if self._source_setup_callback:
131-
self._source_setup_callback()
132-
133-
return wrapper
134-
135-
def get_about_to_finish_callback(self):
136-
# This needs to be called from outside the actor or we lock up.
137-
def wrapper():
138-
if self._about_to_finish_callback:
139-
self.prepare_change()
140-
self._about_to_finish_callback()
141-
142-
if not self._uri or not self._about_to_finish_callback:
143-
self._tags = {}
144-
audio.AudioListener.send("reached_end_of_stream")
145-
else:
146-
audio.AudioListener.send("position_changed", position=0)
147-
audio.AudioListener.send("stream_changed", uri=self._uri)
148-
149-
return wrapper

tests/test_player.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import pytest
22
from gi.repository import GLib
3-
from mopidy.core import PlaybackState
43
from mopidy.models import Album, Artist, Image, Track
4+
from mopidy.types import PlaybackState
55

66
from mopidy_mpris.player import Player
77

tests/test_playlists.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import pytest
2-
from mopidy.audio import PlaybackState
32
from mopidy.models import Track
3+
from mopidy.types import PlaybackState
44

55
from mopidy_mpris.playlists import Playlists
66

0 commit comments

Comments
 (0)