Move next and prevous methods to base backend
This commit is contained in:
parent
f9312b372f
commit
cdbeaa845b
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user