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
1 changed files with 13 additions and 0 deletions

View File

@ -46,11 +46,24 @@ export default function useNowPlaying(props) {
{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", {
detail: np_new
}));
function setPositionState(duration, position) {
navigator.mediaSession.setPositionState({
duration,
position,
});
}
}
if (props.useSse) {