32 lines
699 B
QML
32 lines
699 B
QML
pragma Singleton
|
|
|
|
import QtQuick
|
|
import Quickshell
|
|
import Quickshell.Services.Mpris
|
|
|
|
Singleton {
|
|
id: root
|
|
|
|
property list<MprisPlayer> players: Mpris.players.values
|
|
property MprisPlayer active: players[properties.currentIndex]
|
|
|
|
PersistentProperties {
|
|
id: properties
|
|
|
|
property int currentIndex: 0
|
|
}
|
|
|
|
function nextPlayer() {
|
|
if (players.length == 0) {
|
|
return;
|
|
}
|
|
properties.currentIndex = properties.currentIndex + 1 % players.length;
|
|
}
|
|
|
|
function previousPlayer() {
|
|
if (players.length == 0) {
|
|
return;
|
|
}
|
|
properties.currentIndex = properties.currentIndex - 1 % players.length;
|
|
}
|
|
}
|