extract MprisService singleton, share player state between bar and lock screen
This commit is contained in:
parent
438362c6d1
commit
a7eca009e4
4 changed files with 34 additions and 25 deletions
|
|
@ -13,14 +13,9 @@ M.BarSection {
|
|||
visible: opacity > 0
|
||||
tooltip: ""
|
||||
|
||||
property int _playerIdx: 0
|
||||
readonly property var _players: (Mpris.players.values ?? []).filter(p => p.trackTitle || p.playbackState === MprisPlaybackState.Playing || p.playbackState === MprisPlaybackState.Paused)
|
||||
readonly property MprisPlayer player: _players[_playerIdx] ?? _players[0] ?? null
|
||||
readonly property bool playing: player?.playbackState === MprisPlaybackState.Playing
|
||||
|
||||
// Reset index if current player disappears
|
||||
on_PlayersChanged: if (_playerIdx >= _players.length)
|
||||
_playerIdx = 0
|
||||
readonly property var _players: S.MprisService.players
|
||||
readonly property MprisPlayer player: S.MprisService.player
|
||||
readonly property bool playing: S.MprisService.playing
|
||||
property string _cachedArt: ""
|
||||
property string _artTrack: ""
|
||||
|
||||
|
|
@ -132,9 +127,9 @@ M.BarSection {
|
|||
accentColor: root.accentColor
|
||||
cachedArt: root._cachedArt
|
||||
cavaBars: root._cavaBars
|
||||
playerIdx: root._playerIdx
|
||||
playerIdx: S.MprisService.playerIdx
|
||||
onPlayerSwitched: idx => {
|
||||
root._playerIdx = idx;
|
||||
S.MprisService.switchPlayer(idx);
|
||||
hoverPanel.keepOpen(400);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue