diff --git a/mopidy/backends/__init__.py b/mopidy/backends/__init__.py index 7cbfce5f..3a4cfe4d 100644 --- a/mopidy/backends/__init__.py +++ b/mopidy/backends/__init__.py @@ -112,10 +112,29 @@ class BasePlaybackController(object): raise NotImplementedError def next(self): - raise NotImplementedError + playlist = self.backend.current_playlist.playlist + + if not self.current_track: + self.play() + elif self.playlist_position + 1 >= len(playlist.tracks): + self.stop() + else: + next_track = playlist.tracks[self.playlist_position+1] + self.play(next_track) def previous(self): - raise NotImplementedError + playlist = self.backend.current_playlist.playlist + + if not self.current_track: + self.play() + elif not playlist.tracks: + self.stop() + elif self.playlist_position - 1 > 0: + first_track = playlist.tracks[0] + self.play(first_track) + else: + previous_track = playlist.tracks[self.playlist_position-1] + self.play(previous_track) def pause(self): raise NotImplementedError diff --git a/mopidy/backends/gstreamer.py b/mopidy/backends/gstreamer.py index 22237222..9abdda2f 100644 --- a/mopidy/backends/gstreamer.py +++ b/mopidy/backends/gstreamer.py @@ -85,31 +85,6 @@ class GStreamerPlaybackController(BasePlaybackController): if self.state != self.PLAYING: self.bin.set_state(gst.STATE_PLAYING) - def next(self): - playlist = self.backend.current_playlist.playlist - - if not self.current_track: - self.play() - elif self.playlist_position + 1 >= len(playlist.tracks): - self.stop() - else: - next_track = playlist.tracks[self.playlist_position+1] - self.play(next_track) - - def previous(self): - playlist = self.backend.current_playlist.playlist - - if not self.current_track: - self.play() - elif not playlist.tracks: - self.stop() - elif self.playlist_position - 1 > 0: - first_track = playlist.tracks[0] - self.play(first_track) - else: - previous_track = playlist.tracks[self.playlist_position-1] - self.play(previous_track) - @property def volume(self): return int(self.bin.get_property('volume') * 100)