Best way to share a video/audio URL (YouTube or MP4) with everyone in a room, in sync, on every browser and device?

We run a meeting app on LiveKit (livekit-client2.16, Next.js). The host can share a video or audio link, either a YouTube link or a direct MP4/audio file, and everyone should see and hear it in sync.

What we do now

  • Every participant’s browser plays the link itself, using a player component (react-player). The video is not published into the room.
  • The host’s player broadcasts small SYNC_MEDIA messages over the LiveKit data channel: start, play, pause, seek, stop, and a periodic position snapshot about every 10 seconds.
  • Participants apply those messages. If their position differs from the host’s by more than~0.6 seconds, they seek.
  • A late joiner asks the host for the current state when they connect.
  • Messages carry the sender’s timestamp so receivers can compensate for network delay. We hit a bug where this assumed the two computers’ clocks agree. We now estimate the delay without assuming that.

Where it breaks Because every browser plays the media itself, every browser’s media rules apply to every viewer:

  1. Desktop Chrome and Safari: a share that starts while the viewer’s tab is in the background doesn’t play until they return to the tab. A share already playing keeps going if they switch away.
  2. Android Chrome and mobile Safari: playback pauses as soon as the viewer leaves the tab, even if it was already playing. On return, the picture jumps forward with the sync corrections but stays paused until the host pauses and plays again. We’ve added a fix that resumes playback when the tab becomes visible again, but the audio can’t continue in the background.
  3. Safari: needs a user tap before audio can play, and the embedded YouTube player is the least predictable.
  4. Sync drift: position drifts when viewers buffer or load at different speeds, and recovering depends on the periodic snapshots.
  5. We tested Windows Chrome, macOS Safari and Android Chrome. All show some form of problem, with different symptoms.

What we’ve considered

  • Publish the media into the room instead, so viewers receive it as ordinary call audio and video, which keeps playing in background tabs. For direct MP4/audio links, LiveKit Ingress with a URL input looks like the right fit. Per the docs, it pulls a file from an HTTP server (HLS, MP4 and others), transcodes it, and publishes it as a participant. Viewers subscribe like any other track.
  • Capturing the host’s player in the browser and publishing that track. This seems blocked for YouTube because the player runs in a cross-origin iframe.

Questions

  1. For direct media URLs, is Ingress URL input the recommended way to share a video with everyone? Any experience with latency, start-up time, or how pause, seek and stop are handled? Does the Ingress participant interact well with recording (egress) and with e2ee rooms?
  2. How do people handle seek and pause for an Ingress source? Does the Ingress participant support them, or do you need to recreate the ingress?
  3. For YouTube specifically, is there a better approach than each client embedding its own player and syncing over data messages? We understand embedding is required by YouTube’s terms and capturing isn’t possible.
  4. Is there a recommended pattern for keeping shared-media playback going when a mobile browser tab is hidden, or is “return to the tab” the best anyone can do?
  5. If you’ve built synced playback over data messages, any advice on the sync approach: snapshot interval, drift tolerance, handling clock differences between devices?

Happy to share more details or logs. Thanks!

The way I’ve seen this done is for the user to select a tab in their browser to share so everyone sees and hears that tab as a screen share instead.

I’d separate YouTube playback from direct MP4/HLS sources rather than handling both the same way.

For direct media URLs, one option is to publish the media from the server as a participant in the room. This gives everyone a common source instead of relying on each browser to play the media independently. You’d still need shared playback state for pause/seek, drift correction, and syncing late joiners.

Safari autoplay restrictions and background playback on mobile are separate browser limitations, so server-side ingestion won’t solve those entirely. For YouTube, I’d stick with the permitted embedded-player approach.

If you’re exploring a media-server approach for direct video sources, this Ant Media guide may be useful: https://antmedia.io/webrtc-to-hls-dash/

Disclosure: I work with Ant Media.

@CWilson Totally get that approach, but our requirement is to have video share and audio share as two separate individual features.