forked from Wobbl/Wobuzz
Implemented basic MPRIS integration.
This commit is contained in:
parent
e845c41ca3
commit
9416ac6737
6 changed files with 160 additions and 40 deletions
|
@ -1,11 +1,18 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from PyQt6.QtCore import pyqtSignal
|
||||
from PyQt6.QtGui import QIcon
|
||||
from PyQt6.QtWidgets import QToolBar, QLabel
|
||||
|
||||
from .track_progress_slider import TrackProgressSlider
|
||||
|
||||
|
||||
class TrackControl(QToolBar):
|
||||
toggle_playing_signal = pyqtSignal() # signals for MPRIS
|
||||
next_signal = pyqtSignal()
|
||||
previous_signal = pyqtSignal()
|
||||
stop_signal = pyqtSignal()
|
||||
|
||||
def __init__(self, app, parent=None):
|
||||
super().__init__(parent)
|
||||
|
||||
|
@ -45,9 +52,13 @@ class TrackControl(QToolBar):
|
|||
|
||||
def connect(self):
|
||||
self.previous_button.triggered.connect(self.previous_track)
|
||||
self.toggle_play_button.triggered.connect(self.toggle_playing)
|
||||
self.previous_signal.connect(self.previous_track)
|
||||
self.toggle_play_button.triggered.connect(self.app.player.toggle_playing)
|
||||
self.toggle_playing_signal.connect(self.app.player.toggle_playing)
|
||||
self.stop_button.triggered.connect(self.app.player.stop)
|
||||
self.stop_signal.connect(self.app.player.stop)
|
||||
self.next_button.triggered.connect(self.next_track)
|
||||
self.next_signal.connect(self.next_track)
|
||||
|
||||
def previous_track(self):
|
||||
if self.app.player.current_playlist is not None and self.app.player.current_playlist.has_tracks():
|
||||
|
@ -73,25 +84,6 @@ class TrackControl(QToolBar):
|
|||
|
||||
self.track_progress_slider.update_progress()
|
||||
|
||||
def toggle_playing(self):
|
||||
if self.app.player.playing and self.app.player.paused: # paused
|
||||
self.app.player.unpause()
|
||||
|
||||
elif self.app.player.playing: # playing
|
||||
self.app.player.pause()
|
||||
|
||||
# stopped but tracks in the current playlist
|
||||
elif self.app.player.current_playlist is not None and self.app.player.current_playlist.has_tracks():
|
||||
self.app.player.start_playing()
|
||||
|
||||
elif self.app.player.current_playlist is None:
|
||||
if self.app.settings.latest_playlist is not None:
|
||||
for playlist in self.app.library.playlists: # get loaded playlist by the path of the latest playlist
|
||||
if playlist.path == self.app.settings.latest_playlist:
|
||||
self.app.player.start_playlist(playlist)
|
||||
|
||||
break
|
||||
|
||||
def on_playstate_update(self):
|
||||
if self.app.player.playing:
|
||||
if self.app.player.paused:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue