Commit 44f251b4 authored by Kai Uwe Broulik's avatar Kai Uwe Broulik 🍇

Support "stop" Media Sessions action handler

This was recently added to the spec [1].

[1] https://github.com/WICG/mediasession/commit/3d0f74b2dc48f59090a6ba4b766313716453570f

Differential Revision: https://phabricator.kde.org/D20725
parent 999e790c
......@@ -178,8 +178,22 @@ addCallback("mpris", "playPause", function () {
}
});
// there's no dedicated "stop", simulate it be rewinding and reloading
addCallback("mpris", "stop", function () {
// When available, use the "stop" media sessions action
if (playerCallbacks.indexOf("stop") > -1) {
executeScript(`
function() {
try {
${mediaSessionsClassName}.executeCallback("stop");
} catch (e) {
console.warn("Exception executing 'stop' media sessions callback", e);
}
}
`);
return;
}
// otherwise since there's no "stop" on the player, simulate it be rewinding and reloading
if (activePlayer) {
activePlayer.pause();
activePlayer.currentTime = 0;
......@@ -192,6 +206,7 @@ addCallback("mpris", "stop", function () {
setTimeout(function() {
sendMessage("mpris", "stopped");
}, 1);
return;
}
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment