mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-26 20:53:13 -06:00
Added playback of audio and video attachments in toots
This commit is contained in:
parent
edbc74262a
commit
59409e61a5
@ -335,10 +335,23 @@ class BaseBuffer(base.Buffer):
|
|||||||
def audio(self, url='', *args, **kwargs):
|
def audio(self, url='', *args, **kwargs):
|
||||||
if sound.URLPlayer.player.is_playing():
|
if sound.URLPlayer.player.is_playing():
|
||||||
return sound.URLPlayer.stop_audio()
|
return sound.URLPlayer.stop_audio()
|
||||||
toot = self.get_item()
|
item = self.get_item()
|
||||||
if toot == None:
|
if item == None:
|
||||||
return
|
return
|
||||||
pass
|
urls = utils.get_media_urls(item)
|
||||||
|
if len(urls) == 1:
|
||||||
|
url=urls[0]
|
||||||
|
elif len(urls) > 1:
|
||||||
|
urls_list = dialogs.urlList.urlList()
|
||||||
|
urls_list.populate_list(urls)
|
||||||
|
if urls_list.get_response() == widgetUtils.OK:
|
||||||
|
url=urls_list.get_string()
|
||||||
|
if hasattr(urls_list, "destroy"): urls_list.destroy()
|
||||||
|
if url != '':
|
||||||
|
# try:
|
||||||
|
sound.URLPlayer.play(url, self.session.settings["sound"]["volume"])
|
||||||
|
# except:
|
||||||
|
# log.error("Exception while executing audio method.")
|
||||||
|
|
||||||
def url(self, url='', announce=True, *args, **kwargs):
|
def url(self, url='', announce=True, *args, **kwargs):
|
||||||
if url == '':
|
if url == '':
|
||||||
|
@ -34,3 +34,10 @@ def is_image(toot):
|
|||||||
for media in toot.media_attachments:
|
for media in toot.media_attachments:
|
||||||
if media["type"] == "gifv" or media["type"] == "image":
|
if media["type"] == "gifv" or media["type"] == "image":
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def get_media_urls(toot):
|
||||||
|
urls = []
|
||||||
|
for media in toot.media_attachments:
|
||||||
|
if media.get("type") == "audio" or media.get("type") == "video":
|
||||||
|
urls.append(media.get("url"))
|
||||||
|
return urls
|
Loading…
Reference in New Issue
Block a user