audio: Give the BassPlayer a play_percent property
For calculating what percentage of a song has been played, which is used to determine if a track can be marked as played or not Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
51e8bc295d
commit
e467b784e4
|
@ -41,6 +41,13 @@ class BassPlayer(GObject.GObject):
|
|||
state = Gst.State.PLAYING if playing else Gst.State.PAUSED
|
||||
self.playbin.set_state(state)
|
||||
|
||||
@GObject.Property
|
||||
def play_percent(self):
|
||||
if self.playbin.clock == None or self.duration == 0:
|
||||
return 0
|
||||
runtime = self.playbin.clock.get_time() - self.playbin.base_time
|
||||
return runtime / self.duration
|
||||
|
||||
@GObject.Property
|
||||
def position(self):
|
||||
(res, pos) = self.playbin.query_position(Gst.Format.TIME)
|
||||
|
|
|
@ -46,8 +46,7 @@ class Player(bass.BassPlayer):
|
|||
self.playbin.set_state(state)
|
||||
|
||||
def next(self, *args):
|
||||
duration = self.duration
|
||||
if duration > 0 and (self.runtime() / duration) > (2 / 3):
|
||||
if self.play_percent > (2 / 3):
|
||||
self.track.played()
|
||||
|
||||
(track, cont) = tagdb.Stack.next()
|
||||
|
@ -75,11 +74,6 @@ class Player(bass.BassPlayer):
|
|||
def previous(self, *args):
|
||||
self.play_track(tagdb.Stack.previous())
|
||||
|
||||
def runtime(self):
|
||||
if self.playbin.clock == None:
|
||||
return 0
|
||||
return self.playbin.clock.get_time() - self.playbin.base_time
|
||||
|
||||
@GObject.Signal(arg_types=(tagdb.track.Track, tagdb.track.Track))
|
||||
def track_changed(self, prev, new):
|
||||
pass
|
||||
|
|
Loading…
Reference in New Issue