Test and implement mpris.CanSeek property
This commit is contained in:
parent
c8bc52b4c6
commit
7c2d3cd541
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user