mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -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()
|
||||
|
||||
class URLStream(object):
|
||||
def __init__(self):
|
||||
self.url = None
|
||||
def __init__(self,url=None):
|
||||
self.url = url
|
||||
self.prepared = False
|
||||
log.debug("URL Player initialized")
|
||||
|
||||
@ -130,6 +130,15 @@ class URLStream(object):
|
||||
self.stream.play()
|
||||
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):
|
||||
if hasattr(self, "stream") and self.stream.is_playing == True:
|
||||
self.stream.stop()
|
||||
|
Loading…
Reference in New Issue
Block a user