Fix: Random crashes related to the mediaSession integration
This commit is contained in:
parent
852a7129d1
commit
8f8779a327
|
@ -141,20 +141,20 @@ export const Controls = () => {
|
||||||
navigator.mediaSession.metadata = null;
|
navigator.mediaSession.metadata = null;
|
||||||
if (!initialized) {
|
if (!initialized) {
|
||||||
setInitialized(true);
|
setInitialized(true);
|
||||||
fakeAudio.play();
|
fakeAudio?.play();
|
||||||
if (deviceStatus?.state !== "playing") {
|
if (deviceStatus?.state !== "playing") {
|
||||||
setTimeout(() => fakeAudio.pause(), 5000);
|
setTimeout(() => fakeAudio?.pause(), 5000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
navigator.mediaSession.setActionHandler("previoustrack", handlePrev);
|
navigator.mediaSession.setActionHandler("previoustrack", handlePrev);
|
||||||
navigator.mediaSession.setActionHandler("nexttrack", handleNext);
|
navigator.mediaSession.setActionHandler("nexttrack", handleNext);
|
||||||
navigator.mediaSession.setActionHandler("pause", () => {
|
navigator.mediaSession.setActionHandler("pause", () => {
|
||||||
handlePause();
|
handlePause();
|
||||||
fakeAudio.pause();
|
fakeAudio?.pause();
|
||||||
});
|
});
|
||||||
navigator.mediaSession.setActionHandler("play", () => {
|
navigator.mediaSession.setActionHandler("play", () => {
|
||||||
handlePlay();
|
handlePlay();
|
||||||
fakeAudio.play();
|
fakeAudio?.play();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, []);
|
}, []);
|
||||||
|
|
Loading…
Reference in New Issue