This commit is contained in:
Manuel Cortez 2015-07-03 17:23:25 -05:00
parent a706ebf477
commit cd0977798c
8 changed files with 24 additions and 50 deletions

View File

@ -47,7 +47,7 @@ class bufferController(object):
def get_event(self, ev):
if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown(): event = "interact"
if ev.GetKeyCode() == wx.WXK_RETURN and ev.ControlDown(): event = "audio"
elif ev.GetKeyCode() == wx.WXK_RETURN: event = "url"
elif ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
@ -82,26 +82,6 @@ class bufferController(object):
sound.URLPlayer.stream.volume = self.session.settings["sound"]["volume"]
self.session.sound.play("volume_changed.ogg")
def interact(self):
tweet = self.get_tweet()
url=None
urls = utils.find_urls(tweet)
if len(urls) == 1:
url=urls[0]
elif len(urls) > 1:
urls_list = dialogs.urlList.urlList()
urls_list.populate_list(urls)
if urls_list.get_response() == widgetUtils.OK:
url=urls_list.get_string()
if hasattr(urls_list, "destroy"): urls_list.destroy()
if url != None:
output.speak(_(u"Opening media..."), True)
if sound.URLPlayer.is_playable(url=url, play=True, volume=self.session.settings["sound"]["volume"]) == False:
return webbrowser.open_new_tab(url)
# else:
# output.speak(_(u"Not actionable."), True)
# self.session.sound.play("error.ogg")
def start_stream(self):
pass

View File

@ -1023,11 +1023,6 @@ class Controller(object):
except:
pass
def interact(self):
"Select the best action for the currently focused tweet (audio, geocode, URL, etc)."
buffer = self.get_current_buffer()
buffer.interact()
def url(self, *args, **kwargs):
buffer = self.get_current_buffer()
buffer.url()

View File

@ -18,7 +18,7 @@ user_details = control+win+shift+u
exit = control+win+q
open_timeline = control+win+u
remove_buffer = control+win+backspace
interact = control+win+return
audio = control+win+return
secondary_interact = control+win+b
go_home = control+win+home
go_end = control+win+end

View File

@ -23,7 +23,7 @@ view_item = control+win+v
exit = control+win+f4
open_timeline = control+win+i
remove_buffer = "control+win+'"
interact = control+win+return
audio = control+win+return
volume_up = control+win+alt+up
volume_down = control+win+alt+down
go_home = control+win+home

View File

@ -24,7 +24,7 @@ view_item = alt+win+v
exit = alt+win+f4
open_timeline = alt+win+i
remove_buffer = alt+win+shift+i
interact = alt+win+return
audio = alt+win+return
secondary_interact = alt+shift+win+return
volume_up = alt+win+shift+up

View File

@ -24,7 +24,7 @@ view_item = string(default="control+win+v")
exit = string(default="control+win+f4")
open_timeline = string(default="control+win+i")
remove_buffer = string(default="control+win+shift+i")
interact = string(default="control+win+return")
audio = string(default="control+win+return")
secondary_interact = string(default="control+win+alt+return")
volume_up = string(default="control+win+alt+up")
volume_down = string(default="control+win+alt+down")

View File

@ -24,7 +24,7 @@ view_item = control+win+v
exit = control+win+f4
open_timeline = control+win+i
remove_buffer = control+win+shift+i
interact = control+alt+win+return
audio = control+alt+win+return
url = control+win+return
volume_up = control+win+alt+up
volume_down = control+win+alt+down
@ -51,3 +51,4 @@ view_reverse_geocode = control+win+shift+g
get_trending_topics = control+win+t
find = control+win+{
secondary_interact = control+win+alt+return
interact = control+win+return

View File

@ -116,23 +116,20 @@ class URLStream(object):
self.prepared = True
def play(self, url=None, volume=1.0, stream=None,announce=True):
if self.stop_audio(delete=True):
return
else:
if announce:
output.speak(_(u"Playing..."))
log.debug("Attempting to play an URL...")
if url != None:
self.prepare(url)
elif stream != None:
self.stream=stream
if self.prepared == True:
self.stream = sound_lib.stream.URLStream(url=self.url)
if hasattr(self,'stream'):
self.stream.volume = float(volume)
self.stream.play()
log.debug("played")
call_threaded(self.delete_when_done)
if announce:
output.speak(_(u"Playing..."))
log.debug("Attempting to play an URL...")
if url != None:
self.prepare(url)
elif stream != None:
self.stream=stream
if self.prepared == True:
self.stream = sound_lib.stream.URLStream(url=self.url)
if hasattr(self,'stream'):
self.stream.volume = float(volume)
self.stream.play()
log.debug("played")
call_threaded(self.delete_when_done)
def is_playable(self, url,play=False,volume=1.0):
try:
@ -159,12 +156,13 @@ class URLStream(object):
log.debug("Stopped audio stream.")
except:
log.exception("Exception while stopping stream.")
if delete:
del self.stream
# if delete:
# del self.stream
log.debug("Deleted audio stream.")
return True
else:
return False
@staticmethod
def delete_old_tempfiles():
for f in glob(os.path.join(tempfile.gettempdir(), 'tmp*.wav')):