mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
#35: Add is_playable
This commit is contained in:
parent
0845553047
commit
ea7f5bacf9
13
src/sound.py
13
src/sound.py
@ -94,8 +94,8 @@ class soundSystem(object):
|
|||||||
sound_object.play()
|
sound_object.play()
|
||||||
|
|
||||||
class URLStream(object):
|
class URLStream(object):
|
||||||
def __init__(self):
|
def __init__(self,url=None):
|
||||||
self.url = None
|
self.url = url
|
||||||
self.prepared = False
|
self.prepared = False
|
||||||
log.debug("URL Player initialized")
|
log.debug("URL Player initialized")
|
||||||
|
|
||||||
@ -130,6 +130,15 @@ class URLStream(object):
|
|||||||
self.stream.play()
|
self.stream.play()
|
||||||
log.debug("played")
|
log.debug("played")
|
||||||
|
|
||||||
|
def is_playable(self, url):
|
||||||
|
try:
|
||||||
|
log.debug("Checking URL playability...")
|
||||||
|
self.prepare(url)
|
||||||
|
if self.prepared == True:
|
||||||
|
self.stream = sound_lib.stream.URLStream(url=self.url)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
return False
|
||||||
def stop_audio(self):
|
def stop_audio(self):
|
||||||
if hasattr(self, "stream") and self.stream.is_playing == True:
|
if hasattr(self, "stream") and self.stream.is_playing == True:
|
||||||
self.stream.stop()
|
self.stream.stop()
|
||||||
|
Loading…
Reference in New Issue
Block a user