Bringing Back the Radio

Bringing Back the Radio

2023-01-05
Ashish Saxena

Ashish Saxena

Software Engineer

Building Connection Through Music

During the lockdown, the team decided to build a fun project. Music was brought up, and we had an idea: why not build a radio where everyone can add their tracks and it plays them randomly?

The goal was to boost socializing within the team and bring a sense of togetherness. In a remote-first world, having everyone listening to the same track and bobbing their heads (or questioning someone's music choices) created a shared experience we all missed.

What we achieved

The Impact

  • A shared, synchronized music experience for the whole team.
  • A platform for discovering each other's music tastes.
  • Boosted team morale during challenging times.

It was more than just a technical challenge; it was about building something that felt human and connected us across distances.

Technical Breakdown

The Requirements

  • Has to be a radio where you can't skip tracks and everybody is tuned to the same thing at the same time.
  • Tracks have to be random enough for everybody to get a chance to hear their own tracks.
  • Very simple to operate—just open the URL and it should just work.
  • Simple to operate and cost-effective.

So we started looking into possible workflows. The one that stood out the most and was easiest to implement was a WebSocket-based frontend-backend setup. The backend would send out messages over WS at `connect` and `track_change`, along with playback start time, so the player can automatically seek to the part and play. This enabled local playback to act as a radio.

Since we didn't want to host the mp3 files ourselves, we used YouTube as our playback stream. This was easy as many CLI-based players like `mpd` used YouTube, and `youtube-dl` was an absolute beast of a library for pulling audio URLs.

The flow of the backend was straightforward: Read a random track from a CSV > Lookup the audio URL from the link > Send to clients and queue up another track once the current track playback is finished.

We used the epoch timestamp to avoid timezone mess and for handy seek calculations to sync new users. We used duration information from `youtube-dl` to calculate the sleep time for the code, selecting a new track and broadcasting its information upon completion.

Contribute

If you'd like to implement this in your own team, or want to improve / review the code, the project is available here:

[https://github.com/REAK-INFOTECH-LLP/company-radio/](https://github.com/REAK-INFOTECH-LLP/company-radio/)

#Engineering#Social#Teamwork#RemoteWork

Need help with your project?

Our team can help you build scalable solutions.

Contact Us