Internet radio controlled with a web-based front-end or a REST api.
All components are implemented as docker containers. To start, install Docker and docker-compose and run
docker-compose up
This will start all containers and a web server will be accessible at port 8080.
The radio API is used to control the radio and to manage stations. The endpoints are:
POST /api/play
Parameter | Value |
---|---|
url (optional) |
The station URL to play |
station_id (optional) |
The id of the station to play |
A status message. For example:
{
"volume":100,
"bitrate":"92",
"state":"PLAYING",
"name":"DR P6 BEAT",
"url":"http://live-icy.gss.dr.dk/A/A29H.mp3.m3u",
"title":"Senest spillet: Yuk Foo | Wolf Alice"
}
The state can either be PLAYING
or STOPPED
.
POST /api/stop
A status message.
POST /api/volume
Parameter | Value |
---|---|
vol |
The volume (between 0 and 100) |
A status message.
GET /api/stations
Parameter | Value |
---|---|
is_favorite (optional) |
Boolean value specifying whether to only receive favorite stations |
An array of stations:
[
{
"id":2,
"url":"http://live-icy.gss.dr.dk/A/A03H.mp3.m3u",
"is_favorite":false,
"name":"DR P1"
},
{
"id":3,
"url":"http://live-icy.gss.dr.dk/A/A04H.mp3.m3u",
"is_favorite":false,
"name":"DR P2"
},
{
"id":5,
"url":"http://live-icy.gss.dr.dk/A/A10H.mp3.m3u",
"is_favorite":false,
"name":"DR P4 Nordjylland"
}
]
GET /api/stations/[station_id]
A station object:
{
"id":2,
"url":"http://live-icy.gss.dr.dk/A/A03H.mp3.m3u",
"is_favorite":false,
"name":"DR P1"
}
Stations can be created with POST
requests:
POST /api/stations/
With data containing a new station object.
Stations can be updated with PUT
requests:
PUT /api/stations/[station_id]
and deleted with DELETE
requests:
DELETE /api/stations/[station_id]
The entire project is structured in five Docker containers: app-server (front-end), api-server, web-radio (the radio component), db (PostgreSQL), and nginx.
The front-end is styled with Materialize and implemented using Rivets.js and Socket.io. The web-servers (front-end and API) are implemented with Flask running behind Gunicorn and nginx. The web radio is implemented using Music Player Daemon. All communication between containers is done using GRPC.
To improve the analogue audio output, add the following line to /boot/config.txt
audio_pwm_mode=2
(via this forum post)