mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2026-01-24 21:42:51 -05:00
ipc: move mpris to global controller
This commit is contained in:
@@ -262,4 +262,48 @@ Item {
|
|||||||
|
|
||||||
target: "inhibit"
|
target: "inhibit"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IpcHandler {
|
||||||
|
function list(): string {
|
||||||
|
return MprisController.availablePlayers.map(p => p.identity).join("\n")
|
||||||
|
}
|
||||||
|
|
||||||
|
function play(): void {
|
||||||
|
if (MprisController.activePlayer && MprisController.activePlayer.canPlay) {
|
||||||
|
MprisController.activePlayer.play()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function pause(): void {
|
||||||
|
if (MprisController.activePlayer && MprisController.activePlayer.canPause) {
|
||||||
|
MprisController.activePlayer.pause()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function playPause(): void {
|
||||||
|
if (MprisController.activePlayer && MprisController.activePlayer.canTogglePlaying) {
|
||||||
|
MprisController.activePlayer.togglePlaying()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function previous(): void {
|
||||||
|
if (MprisController.activePlayer && MprisController.activePlayer.canGoPrevious) {
|
||||||
|
MprisController.activePlayer.previous()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function next(): void {
|
||||||
|
if (MprisController.activePlayer && MprisController.activePlayer.canGoNext) {
|
||||||
|
MprisController.activePlayer.next()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop(): void {
|
||||||
|
if (MprisController.activePlayer) {
|
||||||
|
MprisController.activePlayer.stop()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
target: "mpris"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,48 +13,4 @@ Singleton {
|
|||||||
readonly property list<MprisPlayer> availablePlayers: Mpris.players.values
|
readonly property list<MprisPlayer> availablePlayers: Mpris.players.values
|
||||||
|
|
||||||
property MprisPlayer activePlayer: availablePlayers.find(p => p.isPlaying) ?? availablePlayers.find(p => p.canControl && p.canPlay) ?? null
|
property MprisPlayer activePlayer: availablePlayers.find(p => p.isPlaying) ?? availablePlayers.find(p => p.canControl && p.canPlay) ?? null
|
||||||
|
|
||||||
IpcHandler {
|
|
||||||
target: "mpris"
|
|
||||||
|
|
||||||
function list(): string {
|
|
||||||
return root.availablePlayers.map(p => p.identity).join("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
function play(): void {
|
|
||||||
if (root.activePlayer && root.activePlayer.canPlay) {
|
|
||||||
root.activePlayer.play()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function pause(): void {
|
|
||||||
if (root.activePlayer && root.activePlayer.canPause) {
|
|
||||||
root.activePlayer.pause()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function playPause(): void {
|
|
||||||
if (root.activePlayer && root.activePlayer.canTogglePlaying) {
|
|
||||||
root.activePlayer.togglePlaying()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function previous(): void {
|
|
||||||
if (root.activePlayer && root.activePlayer.canGoPrevious) {
|
|
||||||
root.activePlayer.previous()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function next(): void {
|
|
||||||
if (root.activePlayer && root.activePlayer.canGoNext) {
|
|
||||||
root.activePlayer.next()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function stop(): void {
|
|
||||||
if (root.activePlayer) {
|
|
||||||
root.activePlayer.stop()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user