21 lines
676 B
QML
21 lines
676 B
QML
pragma Singleton
|
|
|
|
import QtQuick
|
|
import Quickshell.Services.Mpris
|
|
|
|
QtObject {
|
|
id: root
|
|
|
|
readonly property var players: (Mpris.players.values ?? []).filter(p => p.trackTitle || p.playbackState === MprisPlaybackState.Playing || p.playbackState === MprisPlaybackState.Paused)
|
|
property int playerIdx: 0
|
|
readonly property MprisPlayer player: players[playerIdx] ?? players[0] ?? null
|
|
readonly property bool playing: player?.playbackState === MprisPlaybackState.Playing
|
|
|
|
// Reset index if current player disappears
|
|
onPlayersChanged: if (playerIdx >= players.length)
|
|
playerIdx = 0
|
|
|
|
function switchPlayer(idx) {
|
|
playerIdx = idx;
|
|
}
|
|
}
|