This uses a Schedule to play different Radio stations though out the day/week.
It can also handle a playlist of music sources (UPNP).
Uses VLC (LIBVLC) as the player.
Now features a Web Console;
- to control the player
- play alternate sources
- change Sources or Schedules.
sudo apt-get install vlc
sudo pip3 install python-vlc requests urllib3
Installed into /home/pi/AudioPlayer
Uses: autoplayer_config.json
{
"reloadtimeout": 3000
}
{ "template-nextpvr": {
"clientid": "123",
"hostip": "localhost",
"hostport": 8866,
"pin": "0000"
}
}
Can have as many Sources as wanted
- ID: must be unique
- Name: Name of Source
- Url: Full path to the stream or playlist source
- Image: (optional) Image Url
- Progamme: (optional) NextPvr Programme information lookup
{
"sources": [
{
"id": 1,
"name": "BBC Radio 2",
"url": "http://localhost:8866/live?channel=702&client=230",
"image": "http://localhost:8866/service?method=channel.icon&channel_id=8560",
"programme": {
"nextpvr": {
"hostip": "localhost",
"hostport": 8866,
"pin": "0000",
"channel_id": 8560
}
}
}
]
}
Can have as many Schedules as needed.
The system will start at the top and pick the first schedule that fits.
Therefore it is possible to have overlapping schedules to prevent multiples.
- Day: uses php Day of weeks, (Sunday=0, Monday=1)
- Start & Stop: 24 hour clock, no seconds
- Source: references the source listed
{
"schedules": [
{
"day": [
0,
1,
2,
3,
4,
5,
6
],
"start": "15:00",
"stop": "16:00",
"source": 3
}
]
}
{
"webapi": {
"port": 8007,
"ssl": false
}
}
It is possible to manually control the system.
{
"manual": {
"mode": 0,
"schedule": 1,
"day": 1,
"url": "Url to play",
"title": "Title of what is playing",
"image": "Url of image playing",
"source": 1
}
}
- 0 (null) : (Default) Normal running as per schedule
- 1 : Full stop; play nothing, schedule paused
- 2 : Stop; play nothing, resume at next schedule change
- 3 : Stop; play nothing, resume at next day
- 11 : Play Source; schedule paused
- 12 : Play Source; resume at next schedule change
- 13 : Play Source; resume at next day
- 21 : Play Url; schedule paused
- 22 : Play Url; resume at next schedule change
- 23 : Play Url; resume at next day
Has the current schedule, that should be playing, set when the mode is changed.
Has the current day, set when the mode is changed.
Url to play
Title for the Url
Source ID to play
~/AudioPlayer $ openssl req -x509 -newkey rsa:2048 -nodes -keyout webkey.pem -out webcert.pem -days 365
sudo nano /lib/systemd/system/audioplayer.service
sudo chmod 644 /lib/systemd/system/audioplayer.service
chmod +x /home/pi/AudioPlayer/autoplayer.py
sudo systemctl daemon-reload
sudo systemctl enable audioplayer.service
sudo systemctl start audioplayer.service
[Unit]
Description=TheOwls Audio Player
After=multi-user.target
[Service]
Type=simple
ExecStart=/usr/bin/python3 /home/pi/AudioPlayer/autoplayer.py
Restart=on-abort
User=pi
Group=pi
[Install]
WantedBy=multi-user.target
-
Open Crontab editor (for current user)
~/AudioPlayer $ crontab -e
-
Add line (at bottom)
@reboot && stdbuf -i0 -o0 -e0 sleep 30; /home/pi/AudioPlayer/autoplayer.py >> /home/pi/AudioPlayer/crontab.log 2>&1
-
Save and reboot, it will auto start.