jsmpeg-player icon indicating copy to clipboard operation
jsmpeg-player copied to clipboard

Live audio delayed when autoplay enabled and no user gesture performed in Chrome

Open dumbmoron opened this issue 1 year ago • 1 comments

Describe the bug When streaming live video+audio to the browser via a WebSocket connection, the audio is delayed unless a user clicked on some element before the stream started playing. This is an issue that also affects the original phoboslab/jsmpeg script.

To Reproduce Steps to reproduce the behavior:

  1. Stream video+audio stream over WebSocket (I can provide example code that generates this stream if needed)
  2. Set autoplay to true, load page in browser, but don't click on anything
  3. Wait ~5 seconds, then click on some element
  4. Audio starts playing, but is delayed

I was also able to reproduce this with just streaming audio separately.

Expected behavior The audio should be in sync with the video.

Desktop (please complete the following information):

  • OS: macOS Ventura
  • Browser: Google Chrome
  • Version: latest (114)

Additional context Warning message in console logs:

The AudioContext was not allowed to start. It must be resumed (or created) after a user gesture on the page. https://goo.gl/7K7WLu

dumbmoron avatar Jul 06 '23 11:07 dumbmoron