Rename playlist_position to current_playlist_position
This commit is contained in:
parent
5638604a07
commit
39959a6edf
@ -14,6 +14,8 @@ This change log is used to track all major changes to Mopidy.
|
||||
|
||||
- Removed ``backend.playback.volume`` wrapper. Use ``backend.mixer.volume``
|
||||
directly.
|
||||
- Renamed ``backend.playback.playlist_position`` to
|
||||
``current_playlist_position`` to match naming of ``current_track``.
|
||||
- **[WIP]** Changed API for get/filter/find_exact/search.
|
||||
|
||||
|
||||
|
||||
@ -340,6 +340,17 @@ class BasePlaybackController(object):
|
||||
self._play_time_accumulated = 0
|
||||
self._play_time_started = None
|
||||
|
||||
@property
|
||||
def current_playlist_position(self):
|
||||
"""The position of the current track in the current playlist."""
|
||||
if self.current_track is None:
|
||||
return None
|
||||
try:
|
||||
return self.backend.current_playlist.playlist.tracks.index(
|
||||
self.current_track)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def next_track(self):
|
||||
"""
|
||||
@ -369,24 +380,13 @@ class BasePlaybackController(object):
|
||||
return tracks[0]
|
||||
|
||||
if self.repeat:
|
||||
return tracks[(self.playlist_position + 1) % len(tracks)]
|
||||
return tracks[(self.current_playlist_position + 1) % len(tracks)]
|
||||
|
||||
try:
|
||||
return tracks[self.playlist_position + 1]
|
||||
return tracks[self.current_playlist_position + 1]
|
||||
except IndexError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def playlist_position(self):
|
||||
"""The position in the current playlist."""
|
||||
if self.current_track is None:
|
||||
return None
|
||||
try:
|
||||
return self.backend.current_playlist.playlist.tracks.index(
|
||||
self.current_track)
|
||||
except ValueError:
|
||||
return None
|
||||
|
||||
@property
|
||||
def previous_track(self):
|
||||
"""
|
||||
@ -398,11 +398,11 @@ class BasePlaybackController(object):
|
||||
if self.repeat or self.consume or self.random:
|
||||
return self.current_track
|
||||
|
||||
if self.current_track is None or self.playlist_position == 0:
|
||||
if self.current_track is None or self.current_playlist_position == 0:
|
||||
return None
|
||||
|
||||
return self.backend.current_playlist.playlist.tracks[
|
||||
self.playlist_position - 1]
|
||||
self.current_playlist_position - 1]
|
||||
|
||||
@property
|
||||
def state(self):
|
||||
|
||||
@ -1070,7 +1070,7 @@ class MpdFrontend(object):
|
||||
"""
|
||||
if self.backend.playback.current_track is not None:
|
||||
return self.backend.playback.current_track.mpd_format(
|
||||
position=self.backend.playback.playlist_position)
|
||||
position=self.backend.playback.current_playlist_position)
|
||||
|
||||
@handle_pattern(r'^idle$')
|
||||
@handle_pattern(r'^idle (?P<subsystems>.+)$')
|
||||
@ -1226,7 +1226,7 @@ class MpdFrontend(object):
|
||||
return self.__status_status_songpos()
|
||||
|
||||
def __status_status_songpos(self):
|
||||
return self.backend.playback.playlist_position
|
||||
return self.backend.playback.current_playlist_position
|
||||
|
||||
def __status_status_state(self):
|
||||
if self.backend.playback.state == self.backend.playback.PLAYING:
|
||||
|
||||
@ -397,12 +397,13 @@ class BasePlaybackControllerTest(object):
|
||||
def test_next(self):
|
||||
self.playback.play()
|
||||
|
||||
old_position = self.playback.playlist_position
|
||||
old_position = self.playback.current_playlist_position
|
||||
old_uri = self.playback.current_track.uri
|
||||
|
||||
self.playback.next()
|
||||
|
||||
self.assertEqual(self.playback.playlist_position, old_position+1)
|
||||
self.assertEqual(self.playback.current_playlist_position,
|
||||
old_position+1)
|
||||
self.assertNotEqual(self.playback.current_track.uri, old_uri)
|
||||
|
||||
@populate_playlist
|
||||
@ -422,7 +423,7 @@ class BasePlaybackControllerTest(object):
|
||||
for i, track in enumerate(self.tracks):
|
||||
self.assertEqual(self.playback.state, self.playback.PLAYING)
|
||||
self.assertEqual(self.playback.current_track, track)
|
||||
self.assertEqual(self.playback.playlist_position, i)
|
||||
self.assertEqual(self.playback.current_playlist_position, i)
|
||||
|
||||
self.playback.next()
|
||||
|
||||
@ -584,25 +585,25 @@ class BasePlaybackControllerTest(object):
|
||||
self.assertEqual(self.playback.current_track, self.tracks[1])
|
||||
|
||||
@populate_playlist
|
||||
def test_initial_playlist_position(self):
|
||||
self.assertEqual(self.playback.playlist_position, None)
|
||||
def test_initial_current_playlist_position(self):
|
||||
self.assertEqual(self.playback.current_playlist_position, None)
|
||||
|
||||
@populate_playlist
|
||||
def test_playlist_position_during_play(self):
|
||||
def test_current_playlist_position_during_play(self):
|
||||
self.playback.play()
|
||||
self.assertEqual(self.playback.playlist_position, 0)
|
||||
self.assertEqual(self.playback.current_playlist_position, 0)
|
||||
|
||||
@populate_playlist
|
||||
def test_playlist_position_after_next(self):
|
||||
def test_current_playlist_position_after_next(self):
|
||||
self.playback.play()
|
||||
self.playback.next()
|
||||
self.assertEqual(self.playback.playlist_position, 1)
|
||||
self.assertEqual(self.playback.current_playlist_position, 1)
|
||||
|
||||
@populate_playlist
|
||||
def test_playlist_position_at_end_of_playlist(self):
|
||||
def test_current_playlist_position_at_end_of_playlist(self):
|
||||
self.playback.play(self.tracks[-1])
|
||||
self.playback.end_of_track_callback()
|
||||
self.assertEqual(self.playback.playlist_position, None)
|
||||
self.assertEqual(self.playback.current_playlist_position, None)
|
||||
|
||||
def test_new_playlist_loaded_callback_gets_called(self):
|
||||
new_playlist_loaded_callback = self.playback.new_playlist_loaded_callback
|
||||
|
||||
Loading…
Reference in New Issue
Block a user