Home > bash, debian, linux, music, xfce > Simple webradio playback

Simple webradio playback

I listen to web radio stations but I don’t want to use any player ui for that. All I want is:

  1. Select a station from a list of my favorites and listen to it
  2. Be able to stop current web-radio playback
  3. Never have more than one station playing at the same time

I do it like this:

  • For each radio station save a playlist file (*.pls, *.m3u or sometimes *.asx) in a folder called “radio” on my local machine. I download most of them from the shoutcast or icecast stream directories. I also add one special (empty) file called “none.pls” (which serves to turn off all radio).
  • Add a toolbar to the taskbar that lists the content of the radio folder, i.e. all the webradio playlist files as clickable items. In XFCE add a “Directory Menu” item to the panel.
  • Configure the default app for the playlist mime types mentioned above to be my bash script “radio.sh”. It kills any existing webradio playback and plays the selected playlist file. See below for how to configure mime-type association defaults.
  • Install mpv – the de-facto successor of the now dormant mplayer – to do the actual playback.

This is my little “radio.sh” script (requires the pkill and mpv commands):

#! /bin/bash
pkill -f "mpv --playlist" 
mpv -playlist "$@"

To set this script as the default handler for the most common playlist file types, put the following into ~/.local/share/applications/defaults.list:

[Default Applications]
audio/x-mpegurl=radio.sh.desktop
audio/x-scpls=radio.sh.desktop

Make sure you have a file “radio.sh.desktop” in ~/.local/share/applications or in /usr/local/share/applications with contents like this:

[Desktop Entry]
Exec=radio.sh %U
MimeType=audio/x-mpegurl;audio/x-scpls;video/x-ms-asf
Name=radio.sh
StartupNotify=false
Terminal=false
Type=Application

If I have to use M$ Windows then I do something similar using a taskbar toolbar for the radio folder and the VLC player, configured to run minimized as systray icon.

Advertisements
Categories: bash, debian, linux, music, xfce Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: