Add mobile friendly Streaming Online Internet Radio using HTML5


I have already written about adding an internet radio on to web page/blog. However it uses the media player plugin. Problem with the media player plugin is, it will not play on mobiles or PC/browsers without a media player plugin. In this post I will describe how to add an internet radio player HTML5 audio tag.
Note: There is no one thing fits all solution available. HTML5 also have limitations with respect to audio types supported by different browsers. There are custom libraries available which helps to play maximum formats using audio tags and alternate options such as flash, silver-light, etc(One of them is used here).
This method works best for mp3/ogg format radio streams which are widely supported by popular browsers like Mozilla Firefox, Google Chrome, Internet Explorer, Opera etc. However support can be extended using third party JavaScript/addins.
Well like I have written before, first step is to find the streaming radio link. Please check my previous post for how to find it.
In this case we should also know what format the stream is. Most of the links are mp3. So I would take example of an mp3 shoutcast stream.
This stream can be embedded using the following code.
<audio controls="" preload="none" src=";" type="audio/"></audio>
Preview of the embedded html5 audio element below. This will not be visible if your browser does not support HTML5 audio element or mp3 format.
Now in this element there are following fields.
  1. controls: This tells that the audio controls like play button, mute, seek etc should be visible. Without this noting will be visible.
  2. preload: This is set to none as we are streaming a radio and not an audio file.
  3. src: Streaming radio link. The semicolon ; is important, without which streaming will not happen.(here link is not the link to the website, it is the stream link, see this post)
  4. type: This tells that the stream is mp3 format. Without this the stream may not play.

Read More

Add/Embed online internet radio player on your blog/website


Add online radio on blog or website
In my previous post I have listed some radio stations which can be played online using the embedded player. In this post I will explain how to embed an online internet radio player on a blog/website.
  1. Get the link to the station. This can be extracted from the website of the respective station or a playlist file which is used to play the station or by searching in google.
    Search for the link to station which you want to embed.
    Some examples are
    • mms://
    Some sites/radio also provides playlist files such as .pls, .asx, .ram etc. Try to use these links directly, or download(use a download manager) these files and open using notepad to get the stream.
    Some sites/radio will not have these playlist files, but just the player embedded. In this case use the view source or inspect element option in browser to examine the web page source and find the stream link.
  2. Go to the html view of the blog/website and past the following code at the place where you want the player to appear.
<div id="movId" name="movId" align=center>

<object id="MediaPlayer1" classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" codebase=",0,02,902" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject" width="400" height="300">
  <param id="FileName" name="FileName" value="">
  <param name="animationatStart" value="true">
  <param name="transparentatStart" value="true">
  <param name="autoStart" value="true">
  <param name="showControls" value="true">
  <param name="fullScreen" value="false">
 <embed src="" type="application/x-mplayer2" pluginspage="" name="MediaPlayer" autostart="1" showcontrols="1" width="400" height="45">

In the code where ever the string "" is present, should be replaced by the link to internet radio station which you want to stream.
If you want the page to start streaming/playing automatically, then change in line
<param name="autoStart" value="false">  
false to true and change in line no 10 autostart="1" to autostatrt="0"

And this will be the resullt of the above code.

Click the play button to start playing/streaming the radio station.

Read More