Merge pull request #87 from masonasons/next-gen

Adds functions to seek the playing audio forward or back 5 seconds.
This commit is contained in:
Manuel Cortez 2016-08-11 03:00:31 -05:00 committed by GitHub
commit d729f86898
3 changed files with 39 additions and 0 deletions

View File

@ -175,6 +175,8 @@ class Controller(object):
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_timeline, self.view.timeline)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_favs_timeline, self.view.favs)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.open_conversation, menuitem=self.view.view_conversation)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.seekLeft, menuitem=self.view.seekLeft)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.seekRight, menuitem=self.view.seekRight)
if widgetUtils.toolkit == "wx":
widgetUtils.connect_event(self.view.nb, widgetUtils.NOTEBOOK_PAGE_CHANGED, self.buffer_changed)
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.report_error, self.view.reportError)
@ -478,6 +480,18 @@ class Controller(object):
output.speak(_(u"{0} not found.").format(string,), True)
page.buffer.list.select_item(start)
def seekLeft(self, *args, **kwargs):
try:
sound.URLPlayer.seek(-5)
except:
output.speak("Unable to seek.",True)
def seekRight(self, *args, **kwargs):
try:
sound.URLPlayer.seek(5)
except:
output.speak("Unable to seek.",True)
def edit_keystrokes(self, *args, **kwargs):
editor = keystrokeEditor.KeystrokeEditor()
if editor.changed == True:

View File

@ -117,6 +117,22 @@ class URLStream(object):
log.debug("Transformed URL: %s. Prepared" % (self.url,))
self.prepared = True
def seek(self,step):
pos=self.stream.get_position()
pos=self.stream.bytes_to_seconds(pos)
pos+=step
pos=self.stream.seconds_to_bytes(pos)
if pos<0:
pos=0
self.stream.set_position(pos)
def playpause(self):
if self.stream.is_playing==True:
self.stream.pause()
else:
self.stream.play()
def play(self, url=None, volume=1.0, stream=None,announce=True):
if announce:
output.speak(_(u"Playing..."))

View File

@ -57,6 +57,11 @@ class mainFrame(wx.Frame):
self.clear = buffer.Append(wx.NewId(), _(u"&Clear buffer"))
self.deleteTl = buffer.Append(wx.NewId(), _(u"&Destroy"))
# audio menu
audio = wx.Menu()
self.seekLeft = audio.Append(wx.NewId(), _(u"&Seek back 5 seconds"))
self.seekRight = audio.Append(wx.NewId(), _(u"&Seek forward 5 seconds"))
# Help Menu
help = wx.Menu()
self.doc = help.Append(-1, _(u"&Documentation"))
@ -72,6 +77,7 @@ class mainFrame(wx.Frame):
menuBar.Append(tweet, _(u"&Tweet"))
menuBar.Append(user, _(u"&User"))
menuBar.Append(buffer, _(u"&Buffer"))
menuBar.Append(audio, _(u"&Audio"))
menuBar.Append(help, _(u"&Help"))
self.accel_tbl = wx.AcceleratorTable([
@ -88,7 +94,10 @@ class mainFrame(wx.Frame):
(wx.ACCEL_CTRL, ord('I'), self.timeline.GetId()),
(wx.ACCEL_CTRL|wx.ACCEL_SHIFT, ord('I'), self.deleteTl.GetId()),
(wx.ACCEL_CTRL, ord('M'), self.show_hide.GetId()),
(wx.ACCEL_CTRL, wx.WXK_LEFT, self.seekLeft.GetId()),
(wx.ACCEL_CTRL, ord('P'), self.updateProfile.GetId()),
(wx.ACCEL_CTRL, wx.WXK_RIGHT, self.seekRight.GetId()),
(wx.ACCEL_CTRL, ord(' '), self.seekLeft.GetId()),
])
self.SetAcceleratorTable(self.accel_tbl)