From e0fec7ffa3d34f35aa5b61e5cb635c3c0e72e05a Mon Sep 17 00:00:00 2001 From: qtchaos <72168435+qtchaos@users.noreply.github.com> Date: Fri, 15 Mar 2024 17:30:37 +0200 Subject: [PATCH] fix: add check for setPositionState to avoid TypeError --- src/components/player/internals/MediaSession.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/player/internals/MediaSession.tsx b/src/components/player/internals/MediaSession.tsx index 1dc7e737..73594793 100644 --- a/src/components/player/internals/MediaSession.tsx +++ b/src/components/player/internals/MediaSession.tsx @@ -32,6 +32,9 @@ export function MediaSession() { const updatePositionState = useCallback( (position: number) => { + // If the browser doesn't support setPositionState, return + if (typeof navigator.mediaSession.setPositionState !== "function") return; + // If the updated position needs to be buffered, queue an update if (position > data.progress.buffered) { shouldUpdatePositionState.current = true;