diff --git a/examples/media-player/media-player.ts b/examples/media-player/media-player.ts index 212b9b8..a7a79a6 100644 --- a/examples/media-player/media-player.ts +++ b/examples/media-player/media-player.ts @@ -166,7 +166,11 @@ const initMediaPlayer = async (file: File) => { fileLoaded = true; await startVideoIterator(); - await play(); + + if (audioContext.state === 'running') { + // Start playback automatically if the audio context permits + await play(); + } playerContainer.style.display = ''; @@ -330,6 +334,10 @@ const getPlaybackTime = () => { }; const play = async () => { + if (audioContext!.state === 'suspended') { + await audioContext!.resume(); + } + if (getPlaybackTime() === totalDuration) { // If we're at the end, let's snap back to the start playbackTimeAtStart = 0;