Forward / Rewind buttons
I have created forward and rewind buttons to draw on the info bar. In addition, I have created seek_sec() to seek the song by X seconds. Right now, the seek buttons add +/- 5 seconds to the current position.
This commit is contained in:
parent
f982fab96a
commit
9603e4cef0
|
@ -60,6 +60,18 @@ def seek(prcnt):
|
|||
return call("SEEK", audio.seek, prcnt)
|
||||
|
||||
|
||||
def seek_sec(sec):
|
||||
global audio
|
||||
dur = audio.duration()
|
||||
if dur > 0:
|
||||
prcnt = get_progress() + (1 * sec * 1000000000) / audio.duration()
|
||||
if prcnt > 1:
|
||||
prcnt = 1
|
||||
if prcnt < 0:
|
||||
prcnt = 0
|
||||
seek(prcnt)
|
||||
|
||||
|
||||
def get_progress():
|
||||
global audio
|
||||
dur = audio.duration()
|
||||
|
|
|
@ -62,6 +62,20 @@ class NextButton(Button):
|
|||
def clicked(self, button):
|
||||
LS.collection.plist_next()
|
||||
|
||||
|
||||
class ForwardButton(Button):
|
||||
def __init__(self):
|
||||
Button.__init__(self, gtk.STOCK_MEDIA_FORWARD)
|
||||
def clicked(self, button):
|
||||
LS.music.seek_sec(5)
|
||||
|
||||
|
||||
class RewindButton(Button):
|
||||
def __init__(self):
|
||||
Button.__init__(self, gtk.STOCK_MEDIA_REWIND)
|
||||
def clicked(self, button):
|
||||
LS.music.seek_sec(-5)
|
||||
|
||||
class OpenButton(Button):
|
||||
def __init__(self):
|
||||
Button.__init__(self, gtk.STOCK_OPEN)
|
||||
|
|
|
@ -59,9 +59,11 @@ class InfoBar(Bar):
|
|||
self.pack(self.title, True, True)
|
||||
self.pack(label.TimeLabel())
|
||||
self.pack(label.LengthLabel2())
|
||||
self.pack(button.RewindButton())
|
||||
self.pack(button.PlayButton())
|
||||
self.pack(button.PauseButton())
|
||||
self.pack(button.StopButton())
|
||||
self.pack(button.ForwardButton())
|
||||
self.pack(button.NextButton())
|
||||
self.pack(button.UpButton(up_button))
|
||||
|
||||
|
|
Loading…
Reference in New Issue