The Challenge of Real-Time Sync
Building Verse required seamless synchronization across multiple devices. When one user pauses a track, the other listeners in the jam session need to experience that pause within milliseconds. Standard REST polling was too slow and resource-heavy.
Why Firebase Realtime Database?
I chose Firebase Realtime Database over Firestore for this specific feature because of its low-latency, WebSockets-based architecture. While Firestore is great for user data (and what I used in Progex), Realtime Database excels at syncing small, ephemeral state changes rapidly.
Implementation with Media3
Integrating this with Android's Media3 ExoPlayer required careful state management. We had to account for network latency by syncing timestamps relative to a global NTP clock rather than local device time. This ensured that even if a packet was delayed by 50ms, the audio playback remained perfectly in phase.