Difference between revisions of "Streaming Internet Audio Using Mplayer"

From MythTV Official Wiki
Jump to: navigation, search
(Created page with 'This article is to provide information on how to integrate Internet Radio into Mythtv. This is based on Fm radio but I wanted to post details on how to make it work for Inte…')
m (moved Streaming Audio to Streaming Internet Audio Using Mplayer: This title is generic, and since mythmusic supports shoutcast/http streaming now, it would be better used to describe that process.)
(No difference)

Revision as of 20:06, 14 November 2010

This article is to provide information on how to integrate Internet Radio into Mythtv. This is based on Fm radio but I wanted to post details on how to make it work for Internet Radio too.

Important.png Note: this is NOT a plug-in and is basically a hack but when completed it looks just like a plug-in.

Article from 10,000 feet

What this article is...

This article IS about:

  • Setting up Myth to play streams via Mplayer
  • How-To use programs that other people wrote (and are not affiliated with MythTV)
  • How-To integrate everything with the default MythTV menu theme

What this article is not...

This article IS NOT:

  • How-To perfectly integrate with your particular MythTV GUI (we only cover the default menu theme)
  • A Streaming Plug-in for MythTV

What is required

Only a working installation of MythTV and mplayer is required

Hacking it together

OK, now we are going to write a couple of über-simple shell scripts that we will use to make MythTV work with mlayer. You will notice that these are simple, novice scripts that are pretty crude. This hasn't been called it a "hack" for nothing.

Create files

We need to create a couple of files so find a nice place you can create and execute them from. Personally, I put them in ~/.mythtv

# vi inetradio

## Play Internet Radio Streams on MythtV

if [ "$1" = "gs" ]; then
        mplayer http://somafm.com/startstream=groovesalad.pls

elif [ "$1" = "sa" ]; then
        mplayer http://somafm.com/startstream=secretagent.pls

elif [ "$1" = "xm" ]; then
        mplayer http://somafm.com/startstream=christmas.pls

        exit 1
exit 0

Odiously you are going to want to change the stations here

Now you will want to make this executable:

# chmod a+x inetradio

Test scripts

Now, pull up a command window and run one of the commands we just "made"

$ ./inetradio sa

Did you hear your stream?

Setting up the MythTV GUI

At this point, you should be able to play your streams from the command line with no user intervention... that's 1/2 the battle. Now, we are going to hack a couple of buttons onto the default menu theme.

Important.png Note: If you are currently running MythTV version 0.20 or higher chances are that you're using the default menu theme. No, not the actual MythTV theme, just the menu theme. To check out which one you're using do this in Myth: Utilities / Setup (or Setup) -> Setup -> Appearance -> and at the bottom of the first options page you will see the menu themes selection box, we will be hacking into "Default" so make sure it's set to that one. If you use classic or DVR you can change some of the commands below so that your work is being done on that particular theme (just add /themes/classic or /themes/DVR respectively to the "cd" commands below).

Backup the default theme

# cd /usr/share/mythtv/themes/defaultmenu
# tar cfvz default_backup.tar.gz *.xml

I use the v option because it's an easy way to verify (VIA verbose) what files were put into the tar ball.

Hack the default theme

I'm only going to show you the 2 required changes to get this hack to work.

I added the following to my library.xml file.

# cd /usr/share/mythtv
# vi library.xml
    <text>Internet radio</text>
    <action>MENU inetradio.xml</action>


Then, I created the inetradio.xml file (be sure to add all of the stations you want access to):

# vi inetradio.xml
<mythmenu name="INETRADIOMENU">

      <text>SomaFM Groove Salad</text>
      <action>EXEC ~/.mythtv/inetradio gs</action>

      <text>SomaFM Secret Agent</text>
      <action>EXEC ~/.mythtv/inetradio sa</action>

      <text>SomaFM Xmas Lounge</text>
      <action>EXEC ~/.mythtv/inetradio xm</action>


Tag definitions

OK, now the tag definitions for the above xml file

  • "button" tells the theme to paint a button on the screen
  • "type" tells the theme what image to use for the button
  • "text" tells MythTV what button text to put on the screen
  • "action" tells MythTV what to do when you select the button

Additional Setup and Usage Notes

Screen shots