How to stream audio using jquerymobile
Ok so here's the deal. I'm trying to develop a simple application to stream audio for a radio station.
I'm using phonegap together with the jquerymobile framework to create applications for the iPhone and Android.
Here's my html body code:
- <div data-role="page">
- <div id="radioContent">
- <div data-role="content">
- <a data-role="button" onclick="RadioListenLive()">
- <div id="radiotext">Listen Live</div>
- </a>
- </div>
- </div>
- </div>
and here's my .js code:
- var radioStream = new Audio('http://yp.shoutcast.com/sbin/tunein-station.pls?id=496891');
- var radioPlaying = false;
- function RadioListenLive()
- {
- try
- {
- if (radioPlaying)
- {
- radioStream.pause();
- document.getElementById("radiotext").innerHTML = "Listen Live";
- radioPlaying = false;
- }
- else
- {
- radioStream.play();
- document.getElementById("radiotext").innerHTML = "Click to pause";
- radioPlaying = true;
- }
-
- }
- catch (e)
- {
- alert(e.message);
- }
- }
This works for the iPhone, but not for Android. Is this the correct way to do this? It seems a little bit too.....simple. and I'm confused. I mean, is a valid link all it takes to stream audio??.. I was thinking I would need audio player plugins and such to get it going.
The audio streaming link in this example was found from
http://www.shoutcast.com/ which basically plays a .pls file. Please, any help is appreciated.