Detangle EOT and EOS.

This commit tries to detangle EOS from EOT which we have incorrectly
intermingled. EOS events should only be happening at the end of the playlist
when we are about to stop. EOT handling has been removed / broken in this
change, and will need to be re-added with proper tests.
This commit is contained in:
Thomas Adamcik 2012-10-30 22:30:13 +01:00
parent ac4411ec83
commit e00b590ae9
3 changed files with 12 additions and 3 deletions

View File

@ -56,7 +56,7 @@ class Core(pykka.ThreadingActor, AudioListener, BackendListener):
"""List of URI schemes we can handle"""
def reached_end_of_stream(self):
self.playback.on_end_of_track()
self.playback.on_end_of_stream()
def state_changed(self, old_state, new_state):
# XXX: This is a temporary fix for issue #232 while we wait for a more

View File

@ -312,6 +312,11 @@ class PlaybackController(object):
elif old_state == PlaybackState.PAUSED:
self.pause()
def on_end_of_stream(self):
self._trigger_track_playback_ended()
self.state = PlaybackState.STOPPED
self.current_cp_track = None
def on_end_of_track(self):
"""
Tell the playback controller that end of track is reached.
@ -326,8 +331,6 @@ class PlaybackController(object):
if self.tl_track_at_eot:
self._trigger_track_playback_ended()
self.play(self.tl_track_at_eot)
else:
self.stop(clear_current_track=True)
if self.consume:
self.core.tracklist.remove(tlid=original_tl_track.tlid)

View File

@ -110,6 +110,7 @@ class PlaybackControllerTest(object):
def test_current_track_after_completed_playlist(self):
self.playback.play(self.tracklist.tl_tracks[-1])
self.playback.on_end_of_track()
self.playback.on_end_of_stream()
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
self.assertEqual(self.playback.current_track, None)
@ -338,6 +339,8 @@ class PlaybackControllerTest(object):
self.playback.on_end_of_track()
self.playback.on_end_of_stream()
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
@populate_tracklist
@ -346,6 +349,7 @@ class PlaybackControllerTest(object):
for _ in self.tracks:
self.playback.on_end_of_track()
self.playback.on_end_of_stream()
self.assertEqual(self.playback.current_track, None)
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
@ -510,6 +514,7 @@ class PlaybackControllerTest(object):
def test_tracklist_position_at_end_of_playlist(self):
self.playback.play(self.tracklist.tl_tracks[-1])
self.playback.on_end_of_track()
self.playback.on_end_of_stream()
self.assertEqual(self.playback.tracklist_position, None)
def test_on_tracklist_change_gets_called(self):
@ -815,6 +820,7 @@ class PlaybackControllerTest(object):
def test_end_of_playlist_stops(self):
self.playback.play(self.tracklist.tl_tracks[-1])
self.playback.on_end_of_track()
self.playback.on_end_of_stream()
self.assertEqual(self.playback.state, PlaybackState.STOPPED)
def test_repeat_off_by_default(self):