How would you add synced music and a shared queue to a website?

November 19, 2026 4 answers
Asked by 6n~gimbalwicket_471

I want people to search for tracks, add them to a shared queue, and listen together. Spotify seems to require listeners to have Premium accounts for full tracks, while a YouTube embed may not fit the design. Is there a better way to handle the music source and syncing?

Answers

8r+bracketwren_573

Treat it as a shared playback state rather than trying to send one audio stream to everyone. Let each client play the same track independently. Your server can hold the queue, current track, playback status, and the server time at which playback started.

When someone joins, send them that state and have their player seek to the elapsed position. Broadcast queue changes, skips, pauses, and track changes over a WebSocket or another realtime connection. Compare clocks with the server and check playback position periodically so clients can correct drift.

_g52!plunvexa.4:

A pause needs its own stored position too. Otherwise elapsed time keeps advancing while playback is stopped.

Reply to this answer
_s68~drelvaxo.5

YouTube is a practical option if you can work with a visible embed. Use its player API to control playback, and check the current embed requirements before designing around it. A duration limit on queue submissions would help keep long loops out, and a skip vote could give the room a way to deal with awkward picks.

6n~gimbalwicket_471:

A duration limit sounds useful. I will need to rethink the layout if the player has to stay visible.

Reply to this answer
_u56!quorlano.8

How tight does the sync need to be? For people listening separately, being roughly together may be enough. Multiple speakers in the same room are a much harder target because even small delays can sound like an echo.

Network delay, buffering, device clocks, and audio output latency all affect the result. Scheduling playback for a future server time and correcting drift can help, but don't assume that will make different devices sound perfectly aligned.

Reply to this answer
Vexrilo+7k

The music source and the sync mechanism are separate choices. A shared clock won't get around a provider's account, playback, or display requirements. Check those constraints for the service you choose before building the interface around it.

Reply to this answer

Add your answer

Answers are reviewed before publication.

Related Discussions