Converting tl_track_at_eot property in function with the track having to be

given as an argument
This commit is contained in:
Javier Domingo Cansino 2013-08-07 19:44:00 +02:00
parent 5a87d219ff
commit ec716fba82
2 changed files with 12 additions and 19 deletions

View File

@ -140,10 +140,11 @@ class PlaybackController(object):
return
original_tl_track = self.current_tl_track
next_track = self.core.tracklist.tl_track_at_eot(original_tl_track)
if self.core.tracklist.tl_track_at_eot:
if next_track:
self._trigger_track_playback_ended()
self.play(self.core.tracklist.tl_track_at_eot)
self.play(next_track)
else:
self.stop(clear_current_track=True)

View File

@ -135,9 +135,7 @@ class TracklistController(object):
def tracklist_position(self, tl_track):
"""
The position of the current track in the tracklist.
Read-only.
The position of the given track in the tracklist.
"""
if tl_track is None:
return None
@ -147,12 +145,15 @@ class TracklistController(object):
return None
def get_tl_track_at_eot(self):
def tl_track_at_eot(self, tl_track):
"""
The track that will be played after the given track.
Not necessarily the same track as :meth:`tl_track_at_next`.
"""
# pylint: disable = R0911
# Too many return statements
current_tl_track = self.core.playback.current_tl_track
if not self.tl_tracks:
return None
@ -166,10 +167,10 @@ class TracklistController(object):
if self.random and self._shuffled:
return self._shuffled[0]
if current_tl_track is None:
if tl_track is None:
return self.tl_tracks[0]
position = self.tracklist_position(current_tl_track)
position = self.tracklist_position(tl_track)
if self.repeat and self.single:
return self.tl_tracks[position]
@ -181,15 +182,6 @@ class TracklistController(object):
except IndexError:
return None
tl_track_at_eot = property(get_tl_track_at_eot)
"""
The track that will be played at the end of the current track.
Read-only. A :class:`mopidy.models.TlTrack`.
Not necessarily the same track as :attr:`tl_track_at_next`.
"""
def get_tl_track_at_next(self):
tl_tracks = self.tl_tracks
current_tl_track = self.core.playback.current_tl_track