Skip to content
Play internet radio streams on your PC or Raspberry PI
Python HTML Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
static
template
tests unit test Nov 28, 2019
.gitignore
.travis.yml add python 3.4 and 3.5 to travis Nov 27, 2019
README.md Readme - remove mixer line from mpd.conf example Nov 28, 2019
bluetooth_service.py bluetooth service, volume controls show/hide, readme update Nov 27, 2019
main.py
mpc.py
stations.yml
stations_parser.py change yaml loader Nov 27, 2019
stations_service.py
test.sh
web_ui.py bluetooth service, volume controls show/hide, readme update Nov 27, 2019

README.md

Internet Radio Player

Internet Radio Player with an web interface.

Build Status

Dependencies

mpc and mpc - music player daemon

sudo apt-get update
sudo apt-get install mpd mpc

flask - lightweight web application framework

sudo apt-get install python-pip
pip install -U Flask

oyaml - YAML parser which preserves dict ordering

pip install oyaml

Usage:

main.py [-h] [--host HOST] [--port PORT]
               [--bluetooth-speaker-device BLUETOOTH_SPEAKER_DEVICE]
               [--show-volume-controls {yes,no}]

Internet radio with Web interface for Linux or Raspbian.

optional arguments:
  -h, --help            show this help message and exit
  --host HOST           Web ui host
  --port PORT           Web ui port
  --bluetooth-speaker-device BLUETOOTH_SPEAKER_DEVICE
                        Bluetooth device identifier (taken from bluetoothctl)
  --show-volume-controls {yes,no}
                        Show volume controls, choices: yes / no, default: yes

Control Panel

With default values, the control panel works on address:

http://127.0.0.1:1234/

If you have specified custom host and/or port, create the url by schema:

http://<host>:<port>/

Station list

You can manage the station list in the stations.yml file.

Run tests

sh test.sh

Installation on Raspberry Pi with Raspbian OS.

sudo apt-get update
sudo apt-get install git python3 mpd mpc python-pip
sudo pip3 install -U Flask oyaml
git clone git@github.com:jakubthedeveloper/PythonInternetRadio.git radio

Create startup script, for example in path /home/pi/radio-start.sh, with contents:

cd /home/pi/radio
python3 main.py

You can set custom host and port in the command above.

Test the web ui in your computer/phone/tablet browser, in my network the Raspberry Pi has the address: 192.168.123.7, so I open the following url in my browser:

http://192.168.123.7:1234/

Connect headphones or speakers to the Raspberry Pi and click play in Web UI.

Cron

Add startup script to cron:

crontab -e

and enter the following line:

@reboot sh /home/pi/radio-start.sh

Reboot Rasperry Pi to check if the cron entry works:

sudo reboot

Bluetooth speaker

In you want to connect a Bluetooth speaker to Raspberry Pi you have to install Bluez-alsa. I managed to do it using the instruction on the page how-to-stream-sound-to-a-bluetooth-device-from-a-raspberry-pi-zero

Here is my audio output config in /etc/mpd.conf that works with Creative Muvo 2c bluetooth speaker:

audio_output {
       type            "alsa"
       name            "BluetoothSpeaker"
       device          "bluealsa:DEV=XX:XX:XX:XX:XX:XX,PROFILE=a2dp" # replace XX:XX:XX:XX:XX:XX with bluetooth device id
}

Example ecosystem

Example ecosystem for Raspberry Radio

Blog

[PL] Artykuł na blogu: Python – odtwarzacz radia internetowego – Linux i Raspberry Pi

You can’t perform that action at this time.