Improved play function. Now it should play only an audio at the same time
This commit is contained in:
parent
4fd4bd07a4
commit
4acf363f3e
@ -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()
|
||||
# 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:
|
||||
|
@ -93,6 +93,7 @@ def compose_status(status, session):
|
||||
return [user, message, created_at]
|
||||
|
||||
def compose_audio(audio, session):
|
||||
if audio == False: return [_(u"Audio removed from library"), "", ""]
|
||||
return [audio["title"], audio["artist"], utils.seconds_to_string(audio["duration"])]
|
||||
|
||||
class vkSession(object):
|
||||
@ -160,6 +161,7 @@ class vkSession(object):
|
||||
self.authorise()
|
||||
else:
|
||||
self.authorise()
|
||||
self.get_my_data()
|
||||
|
||||
def authorise(self):
|
||||
self.vk.login(self.settings["vk"]["user"], self.settings["vk"]["password"])
|
||||
@ -235,3 +237,6 @@ class vkSession(object):
|
||||
self.db["users"][i["uid"]] = u"{0} {1}".format(i["first_name"], i["last_name"])
|
||||
for i in data["groups"]:
|
||||
self.db["groups"][i["gid"]] = i["name"]
|
||||
|
||||
def get_my_data(self):
|
||||
self.user_id = self.vk.client.users.get(fields="uid")[0]["uid"]
|
Loading…
Reference in New Issue
Block a user