Skip to main content

Music Synchronization Extension

About Music Synchronization

Music synchronization can be a challenging task but necessary if you build an app where users can listen to the same music together. The Music Synchronization Extension can take care of the heavy lifting and let you to focus on other parts of your app. After integration, you get automatic clock synchronization and a flexible music player.

In order to synchronize two music players you need to make sure the following data message gets from the DJ user to the listeners. You can use any channel to achieve this (such as custom web socket server or WebRTC data channel).

"timestamp": Timestamp, // Timestamp that shows when this JSON message was created
"trackID": String, // Current track ID that is loaded in the player
"position": Number, // Current track position in ms
"isPlaying": Bool, // Shows whether track is playing or not
"nextTrackID": String, // Next track ID that should be queued in the player

This Music Synchronization Extension provides the following audio nodes for a Switchboard SDK audio graph:

SynchronizedMusicPlayerNodeA music player that can emit and process music synchronization messages. It can play local files and web streams too.