I‘m currently working on Safari App Extension whitch control the playback of media content on the website. Is there a way to have macOS Now Playing widget with next \ previous buttons with fully configured MediaSession handlers? So. What i mean. When i configure MediaSession with this code
const actionHandlers = [
["play", () => player.togglePause()],
["pause", () => player.togglePause()],
["previoustrack", () => player.prev()],
["nexttrack", () => player.next()],
["stop", () => { /* ... */ }],
["seekbackward", (details) => { shortSeek() }],
["seekforward", (details) => { shortSeek() }],
["seekto", (details) => { player.setPosition(details["seekTime"]) }]
];
for (const [action, handler] of actionHandlers) {
try {
navigator.mediaSession.setActionHandler(action, handler);
} catch (error) {
console.log("The media session action ", action, " is not supported yet.");
};
};
Now Playing widget looks like this
widget have seekforward and seekbackward buttons, but i expected that the widget will have next \ previous buttons like so
When i configure Mediasession like this
const actionHandlers = [
["play", () => player.togglePause()],
["pause", () => player.togglePause()],
["previoustrack", () => player.prev()],
["nexttrack", () => player.next()],
["stop", () => { /* ... */ }],
["seekbackward", null],
["seekforward", null],
["seekto", (details) => { player.setPosition(details["seekTime"]) }]
];
for (const [action, handler] of actionHandlers) {
try {
navigator.mediaSession.setActionHandler(action, handler);
} catch (error) {
console.log("The media session action ", action, " is not supported yet.");
};
};
widget looks as i expected. Any suggestions? Thank you.