4
0
mirror of https://github.com/AzuraCast/AzuraCast.git synced 2024-06-14 13:16:37 +00:00

Now playing position (#7001)

* Add position state to now playing

* fix seeking bug
This commit is contained in:
jpcastberg 2024-03-09 12:14:00 -08:00 committed by GitHub
parent 035799679b
commit 7d083ab93d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -46,11 +46,24 @@ export default function useNowPlaying(props) {
{src: np_new.now_playing.song.art} {src: np_new.now_playing.song.art}
] ]
}); });
setPositionState(np_new.now_playing.duration, np_new.now_playing.elapsed);
navigator.mediaSession.setActionHandler("seekto", function () {
setPositionState(np_new.now_playing.duration, np_new.now_playing.elapsed);
});
} }
document.dispatchEvent(new CustomEvent("now-playing", { document.dispatchEvent(new CustomEvent("now-playing", {
detail: np_new detail: np_new
})); }));
function setPositionState(duration, position) {
navigator.mediaSession.setPositionState({
duration,
position,
});
}
} }
if (props.useSse) { if (props.useSse) {