Skip to content

Instantly share code, notes, and snippets.

@bng44270
Created March 6, 2023 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bng44270/ffeaf2c357f75dde99664b11e99a4657 to your computer and use it in GitHub Desktop.
Save bng44270/ffeaf2c357f75dde99664b11e99a4657 to your computer and use it in GitHub Desktop.
Internet Radio Station Player (GUI)
#!/bin/bash
###################################
#
# Radio Player (GUI)
#
# Requires zenity
#
# Usage:
#
# 1) Create M3U playlist file using the following syntax:
#
# #EXTINF:0,<Radio Station Name>
# <Radio Station URL>
#
# 2) Repease step 1 for each radio station
#
# 3) Update the PLAYLIST variable below with the full
# path to the M3U playlist you created
#
###################################
PLAYLIST="/path/to/playlist.m3u"
while true; do
STATION="$(awk 'BEGIN { FS="," } /^#EXTINF/ { print $2 }' < $PLAYLIST | zenity --list --column="Station" --title="Radio Player" --width=300 --height=530)"
if [ $? -eq 1 ]; then
break
fi
URL="$(grep -A1 $STATION $PLAYLIST | tail -n1)"
ffplay -loglevel 8 -nodisp "$URL" &
zenity --info --text="Playing\n$STATION" --width=300 --ok-label="Stop" --title="Radio Player"
FFPLAY_PID="$(ps -ef | grep "[f]fplay.*$URL" | awk '{ print $2 }')"
kill -9 $FFPLAY_PID
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment