mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -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):
|
||||
if sound.URLPlayer.player.is_playing():
|
||||
return sound.URLPlayer.stop_audio()
|
||||
toot = self.get_item()
|
||||
if toot == None:
|
||||
item = self.get_item()
|
||||
if item == None:
|
||||
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):
|
||||
if url == '':
|
||||
|
@ -33,4 +33,11 @@ def is_image(toot):
|
||||
# Checks firstly for Mastodon native videos and audios.
|
||||
for media in toot.media_attachments:
|
||||
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