mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Play URL now works with all URL
This commit is contained in:
parent
4c56850da6
commit
eb4301aeb5
11
src/sound.py
11
src/sound.py
@ -97,13 +97,21 @@ class URLStream(object):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.url = None
|
self.url = None
|
||||||
self.prepared = False
|
self.prepared = False
|
||||||
|
log.debug("URL Player initialized")
|
||||||
|
|
||||||
def prepare(self, url):
|
def prepare(self, url):
|
||||||
|
log.debug("Preparing URL: %s" % (url,))
|
||||||
self.prepared = False
|
self.prepared = False
|
||||||
self.url = url_shortener.unshorten(url)
|
self.url = url_shortener.unshorten(url)
|
||||||
|
log.debug("Expanded URL: %s" % (self.url,))
|
||||||
if self.url != None:
|
if self.url != None:
|
||||||
transformer = audio_services.find_url_transformer(self.url)
|
transformer = audio_services.find_url_transformer(self.url)
|
||||||
self.url = transformer(self.url)
|
self.url = transformer(self.url)
|
||||||
|
log.debug("Transformed URL: %s. Prepared" % (self.url,))
|
||||||
|
self.prepared = True
|
||||||
|
else:
|
||||||
|
self.url = url
|
||||||
|
log.debug("Transformed URL: %s. Prepared" % (self.url,))
|
||||||
self.prepared = True
|
self.prepared = True
|
||||||
|
|
||||||
def play(self, url, volume=1.0):
|
def play(self, url, volume=1.0):
|
||||||
@ -111,13 +119,16 @@ class URLStream(object):
|
|||||||
output.speak(_(u"Stopped"))
|
output.speak(_(u"Stopped"))
|
||||||
self.stream.stop()
|
self.stream.stop()
|
||||||
del self.stream
|
del self.stream
|
||||||
|
log.debug("Stream stopped")
|
||||||
else:
|
else:
|
||||||
output.speak(_(u"Playing..."))
|
output.speak(_(u"Playing..."))
|
||||||
|
log.debug("Attempting to play an URL...")
|
||||||
self.prepare(url)
|
self.prepare(url)
|
||||||
if self.prepared == True:
|
if self.prepared == True:
|
||||||
self.stream = sound_lib.stream.URLStream(url=self.url)
|
self.stream = sound_lib.stream.URLStream(url=self.url)
|
||||||
self.stream.volume = float(volume)
|
self.stream.volume = float(volume)
|
||||||
self.stream.play()
|
self.stream.play()
|
||||||
|
log.debug("played")
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def delete_old_tempfiles():
|
def delete_old_tempfiles():
|
||||||
|
Loading…
Reference in New Issue
Block a user