forked from Wobbl/Wobuzz
Implemented MPRIS metadata "mpris:artUrl"
This commit is contained in:
parent
9416ac6737
commit
a236370d47
3 changed files with 29 additions and 1 deletions
|
@ -1,5 +1,6 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import time
|
||||
import threading
|
||||
import pygame.mixer
|
||||
|
@ -40,6 +41,8 @@ class Player:
|
|||
self.paused = False
|
||||
|
||||
self.app.gui.on_playstate_update()
|
||||
|
||||
self.export_cover_art_tmp()
|
||||
self.mpris_server.exec_async(self.mpris_server.set_metadata(self.current_playlist.current_track.metadata))
|
||||
|
||||
# cache next track so it immediately starts when the current track finishes
|
||||
|
@ -217,3 +220,23 @@ class Player:
|
|||
self.start_playlist(playlist)
|
||||
|
||||
break
|
||||
|
||||
def export_cover_art_tmp(self) -> None:
|
||||
"""
|
||||
Export the cover art of the current track to /tmp/wobuzz/current_cover, so MPRIS can access it.
|
||||
"""
|
||||
|
||||
metadata = self.current_playlist.current_track.metadata
|
||||
|
||||
art_tmp_path = self.app.utils.tmp_path + "/cover_cache/"
|
||||
art_path = art_tmp_path + metadata.path.split("/")[-1][:-4]
|
||||
|
||||
if os.path.isfile(art_path): # cover art already exported
|
||||
return
|
||||
|
||||
if not os.path.exists(art_tmp_path):
|
||||
os.makedirs(art_tmp_path)
|
||||
|
||||
file = open(art_path, "wb")
|
||||
file.write(metadata.images.any.data)
|
||||
file.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue