Improved play function. Now it should play only an audio at the same time

This commit is contained in:
2016-02-19 17:30:11 -06:00
parent 4fd4bd07a4
commit 4acf363f3e
2 changed files with 14 additions and 4 deletions

View File

@@ -17,13 +17,18 @@ class audioPlayer(object):
self.is_playing = False
self.stream = None
self.vol = 100
self.is_working = False
def play(self, url):
if self.stream != None and self.stream.is_playing == True:
self.stream.stop()
self.stream = URLStream(url=url)
self.stream.volume = self.vol/100.0
self.stream.play()
# Make sure that there are no other sounds trying to be played.
if self.is_working == False:
self.is_working = True
self.stream = URLStream(url=url)
self.stream.volume = self.vol/100.0
self.stream.play()
self.is_working = False
def stop(self):
if self.stream != None and self.stream.is_playing == True: