diff --git a/mopidy/frontends/mpris.py b/mopidy/frontends/mpris.py index a515412c..b3c2af31 100644 --- a/mopidy/frontends/mpris.py +++ b/mopidy/frontends/mpris.py @@ -155,8 +155,7 @@ class MprisObject(dbus.service.Object): 'CanPlay': (False, None), # TODO True if CanControl and backend.playback.current_track 'CanPause': (False, None), - # TODO Set to True when the rest is implemented - 'CanSeek': (False, None), + 'CanSeek': (self.get_CanSeek, None), 'CanControl': (self.get_CanControl, None), } @@ -398,6 +397,13 @@ class MprisObject(dbus.service.Object): def get_Position(self): return self.backend.playback.time_position.get() * 1000 + def get_CanSeek(self): + if not self.get_CanControl(): + return False + # XXX Should be changed to vary based on capabilities of the current + # track if Mopidy starts supporting non-seekable media, like streams. + return True + def get_CanControl(self): # TODO This could be a setting for the end user to change. return True diff --git a/tests/frontends/mpris/player_interface_test.py b/tests/frontends/mpris/player_interface_test.py index 26e46184..8c8fb36b 100644 --- a/tests/frontends/mpris/player_interface_test.py +++ b/tests/frontends/mpris/player_interface_test.py @@ -177,6 +177,16 @@ class PlayerInterfaceTest(unittest.TestCase): result = self.mpris.Get(mpris.PLAYER_IFACE, 'MaximumRate') self.assert_(result >= 1.0) + def test_can_seek_is_true_if_can_control_is_true(self): + self.mpris.get_CanControl = lambda *_: True + result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanSeek') + self.assertTrue(result) + + def test_can_seek_is_false_if_can_control_is_false(self): + self.mpris.get_CanControl = lambda *_: False + result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanSeek') + self.assertFalse(result) + def test_can_control_is_true(self): result = self.mpris.Get(mpris.PLAYER_IFACE, 'CanControl') self.assertTrue(result)