@@ -69,10 +69,16 @@ def is_discord_running():
6969def update_discord_rpc (title , artist , image , mainwindow ):
7070 if is_discord_running ():
7171 try :
72+ if title == "" and artist == "" and image == "" :
73+ mainwindow .RPC .clear (pid = os .getpid ())
74+ mainwindow .RPC .close ()
75+ mainwindow .RPC .connect ()
76+ return
77+ # Mise à jour de la présence avec les nouvelles informations
7278 mainwindow .RPC .update (details = title , state = artist , large_image = image , large_text = "Entrain d'écouter" )
73- print ("Réussite de la mise à jour du RPC Discord" )
79+ print ("Réussite de la mise à jour de la présence Discord" )
7480 except Exception as e :
75- print (f"Erreur lors de la mise à jour du RPC Discord: { e } " )
81+ print (f"Erreur lors de la mise à jour de la présence Discord: { e } " )
7682
7783class WaveformWorker (QThread ):
7884 waveformReady = pyqtSignal (np .ndarray )
@@ -238,7 +244,7 @@ def __init__(self):
238244 def resize_cover (self , cover_path , size = (252 , 252 )):
239245 with Image .open (cover_path ) as img :
240246 # Redimensionner l'image
241- img .thumbnail (size , Image .LANCZOS )
247+ img .thumbnail (size , Image .Resampling . LANCZOS )
242248
243249 # Convertir en RGB si l'image est en mode RGBA
244250 if img .mode == 'RGBA' :
@@ -253,6 +259,10 @@ def resize_cover(self, cover_path, size=(252, 252)):
253259 async def envoyer_image (self , chemin_fichier , title , artist ):
254260 if is_discord_running ():
255261 try :
262+ if chemin_fichier == "" and title == "" and artist == "" :
263+ print ("Aucune information fournie pour l'image, la mise à jour RPC sera vide." )
264+ threading .Thread (target = update_discord_rpc , args = ("" , "" , "" , self )).start ()
265+ return
256266 uploaded_image = None
257267 image_path_sans_prefixe = chemin_fichier [7 :] if chemin_fichier .startswith ("file://" ) else chemin_fichier
258268 if image_path_sans_prefixe in self .uploaded_images_cache :
@@ -880,9 +890,11 @@ def on_clear_clicked(self):
880890 self .waveformPlot .getAxis ('left' ).setVisible (False )
881891 self .waveformPlot .getAxis ('bottom' ).setVisible (False )
882892 if is_discord_running ():
883- if self .RPC is not None :
884- self .RPC .close ()
885-
893+ try :
894+ asyncio .create_task (self .play_track_async ("" , "" , "" ))
895+ print ("Réussite de la remise à zéro du RPC Discord" )
896+ except Exception as e :
897+ print (f"Erreur lors de la tentative de retirer les infos de la connexion RPC : { e } " )
886898
887899 def apply_style_to_button (self , button , activate ):
888900 if isinstance (button , QPushButton ) and activate :
0 commit comments