2023-09-27 05:41:52 +00:00
|
|
|
// SPDX-FileCopyrightText: 2021-2023 Devin Lin <devin@kde.org>
|
|
|
|
|
// SPDX-FileCopyrightText: 2016 Kai Uwe Broulik <kde@privat.broulik.de>
|
|
|
|
|
// SPDX-License-Identifier: LGPL-2.0-or-later
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-05-13 15:15:52 +00:00
|
|
|
import QtQuick
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-09-27 05:41:52 +00:00
|
|
|
import org.kde.plasma.private.mpris as Mpris
|
2024-03-09 05:49:35 +00:00
|
|
|
import org.kde.kitemmodels
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-09-27 05:41:52 +00:00
|
|
|
QtObject {
|
2024-03-09 05:49:35 +00:00
|
|
|
property var baseMpris2Model: Mpris.Mpris2Model {}
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2024-03-09 05:49:35 +00:00
|
|
|
property var mpris2Model: KSortFilterProxyModel {
|
|
|
|
|
sourceModel: baseMpris2Model
|
2023-09-27 05:41:52 +00:00
|
|
|
|
2024-03-09 05:49:35 +00:00
|
|
|
// filter and ignore first element, because it's the multiplexer (which will look like a duplicate source)
|
|
|
|
|
filterRowCallback: function(source_row, source_parent) {
|
|
|
|
|
return source_row !== 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2022-04-09 01:48:42 +00:00
|
|
|
function startOperation(src, op) {
|
|
|
|
|
var service = serviceForSource(src)
|
|
|
|
|
var operation = service.operationDescription(op)
|
|
|
|
|
return service.startOperationCall(operation)
|
|
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-09-27 05:41:52 +00:00
|
|
|
function setIndex(index) {
|
2024-03-11 04:55:37 +00:00
|
|
|
baseMpris2Model.currentIndex = index + 1; // account for first row being gone (multiplexer)
|
2022-04-09 01:48:42 +00:00
|
|
|
}
|
2023-09-27 05:41:52 +00:00
|
|
|
function goPrevious() {
|
2024-03-11 04:55:37 +00:00
|
|
|
baseMpris2Model.currentPlayer.Previous();
|
2022-04-09 01:48:42 +00:00
|
|
|
}
|
2023-09-27 05:41:52 +00:00
|
|
|
function goNext() {
|
2024-03-11 04:55:37 +00:00
|
|
|
baseMpris2Model.currentPlayer.Next();
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
2023-09-27 05:41:52 +00:00
|
|
|
function playPause() {
|
2024-03-11 04:55:37 +00:00
|
|
|
baseMpris2Model.currentPlayer.PlayPause();
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|