mirror of
https://github.com/ThaUnknown/miru.git
synced 2026-03-28 16:08:42 +00:00
media session cont., fixes
This commit is contained in:
parent
8874a03234
commit
d0a9354886
2 changed files with 14 additions and 3 deletions
|
|
@ -107,6 +107,7 @@ function alRequest(a) {
|
|||
genres
|
||||
coverImage {
|
||||
extraLarge
|
||||
medium
|
||||
}
|
||||
bannerImage
|
||||
synonyms
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ video.addEventListener("loadedmetadata", updateDisplay);
|
|||
video.addEventListener("ended", bnext);
|
||||
video.addEventListener("waiting", isBuffering);
|
||||
video.addEventListener("timeupdate", updateDisplay);
|
||||
video.addEventListener("timeupdate", updatePositionState);
|
||||
playPause.addEventListener("click", bpp);
|
||||
|
||||
|
||||
|
|
@ -286,7 +287,7 @@ document.onkeydown = function (a) {
|
|||
bfull();
|
||||
break;
|
||||
case "s":
|
||||
seek(89);
|
||||
seek(85);
|
||||
break;
|
||||
case "ArrowLeft":
|
||||
seek(-2);
|
||||
|
|
@ -300,10 +301,10 @@ document.onkeydown = function (a) {
|
|||
function nowPlaying(sel) {
|
||||
nowPlaying = sel
|
||||
if ('mediaSession' in navigator) {
|
||||
|
||||
navigator.mediaSession.metadata = new MediaMetadata({
|
||||
title: !!nowPlaying[0].title.english ? nowPlaying[0].title.english : nowPlaying[0].title.romaji,
|
||||
artist: 'Miru',
|
||||
artist: "Episode " + nowPlaying[1],
|
||||
album: "Miru",
|
||||
artwork: [
|
||||
{
|
||||
src: nowPlaying[0].coverImage.medium,
|
||||
|
|
@ -314,6 +315,15 @@ function nowPlaying(sel) {
|
|||
});
|
||||
}
|
||||
}
|
||||
function updatePositionState() {
|
||||
if ('setPositionState' in navigator.mediaSession) {
|
||||
navigator.mediaSession.setPositionState({
|
||||
duration: video.duration || 0,
|
||||
playbackRate: video.playbackRate || 0,
|
||||
position: video.currentTime || 0
|
||||
});
|
||||
}
|
||||
}
|
||||
if ('mediaSession' in navigator) {
|
||||
navigator.mediaSession.setActionHandler('play', bpp);
|
||||
navigator.mediaSession.setActionHandler('pause', bpp);
|
||||
|
|
|
|||
Loading…
Reference in a new issue