Use tlid instead of full tl_track
To export/restore the PlayState the tlid is enough.
This commit is contained in:
parent
abe3d67bc1
commit
74344f2b19
@ -545,7 +545,7 @@ class PlaybackController(object):
|
||||
def _export_state(self):
|
||||
"""Internal method for :class:`mopidy.Core`."""
|
||||
return models.PlaybackState(
|
||||
tl_track=self.get_current_tl_track(),
|
||||
tlid=self.get_current_tlid(),
|
||||
position=self.get_time_position(),
|
||||
state=self.get_state())
|
||||
|
||||
@ -559,7 +559,7 @@ class PlaybackController(object):
|
||||
new_state = PlaybackState.PLAYING
|
||||
if 'play-last' in coverage:
|
||||
new_state = state.state
|
||||
if state.tl_track is not None:
|
||||
if state.tlid is not None:
|
||||
if PlaybackState.PLAYING == new_state:
|
||||
self.play(tl_track=state.tl_track)
|
||||
self.play(tlid=state.tlid)
|
||||
# TODO: seek to state.position?
|
||||
|
||||
@ -416,16 +416,16 @@ class PlaybackState(ValidatedImmutableObject):
|
||||
State of the playback controller.
|
||||
Internally used for import/export of current state.
|
||||
|
||||
:param tl_track: current track
|
||||
:type tl_track: :class:`TlTrack`
|
||||
:param tlid: current track tlid
|
||||
:type tlid: int
|
||||
:param position: play position
|
||||
:type position: int
|
||||
:param state: playback state
|
||||
:type state: :class:`validation.PLAYBACK_STATES`
|
||||
"""
|
||||
|
||||
# The current playing track. Read-only.
|
||||
tl_track = fields.Field(type=TlTrack)
|
||||
# The tlid of current playing track. Read-only.
|
||||
tlid = fields.Integer(min=1)
|
||||
|
||||
# The playback position. Read-only.
|
||||
position = fields.Integer(min=0)
|
||||
|
||||
@ -948,7 +948,7 @@ class CorePlaybackExportRestoreTest(BaseTest):
|
||||
self.replay_events()
|
||||
|
||||
state = PlaybackState(
|
||||
position=0, state='playing', tl_track=tl_tracks[1])
|
||||
position=0, state='playing', tlid=tl_tracks[1].tlid)
|
||||
value = self.core.playback._export_state()
|
||||
|
||||
self.assertEqual(state, value)
|
||||
@ -961,7 +961,7 @@ class CorePlaybackExportRestoreTest(BaseTest):
|
||||
self.assertEqual('stopped', self.core.playback.get_state())
|
||||
|
||||
state = PlaybackState(
|
||||
position=0, state='playing', tl_track=tl_tracks[2])
|
||||
position=0, state='playing', tlid=tl_tracks[2].tlid)
|
||||
coverage = ['play-always']
|
||||
self.core.playback._restore_state(state, coverage)
|
||||
self.replay_events()
|
||||
@ -978,7 +978,7 @@ class CorePlaybackExportRestoreTest(BaseTest):
|
||||
self.assertEqual('stopped', self.core.playback.get_state())
|
||||
|
||||
state = PlaybackState(
|
||||
position=0, state='playing', tl_track=tl_tracks[2])
|
||||
position=0, state='playing', tlid=tl_tracks[2].tlid)
|
||||
coverage = ['other']
|
||||
self.core.playback._restore_state(state, coverage)
|
||||
self.replay_events()
|
||||
|
||||
Loading…
Reference in New Issue
Block a user