Oct. 21, 2009Guillermo Perez Farq
I'm not being able to make a playlist. I need to play an alternative radio when our shoutcast radio is off.
If i write the xml putting the alternative radio first, it sounds. But if i write it second, and my radio is not streaming, then it just doesn't play.
This is the file:
<?xml version='1.0' encoding='UTF-8'?>
<playlist version="1" xmlns="http://xspf.org/ns/0/" xmlns:jwplayer="http://developer.longtailvideo.com/trac/wiki/FlashFormats">
<trackList>
<track>
<creator>
ASTARBAGUS
</creator>
<title>
ASTARBAGUS - The Asian Touch
</title>
<location>
http://astarbagus.no-ip.biz:8000/;*.nsv
</location>
<info>astarbagus@hotmail.com</info>
<image>
http://www.astarbagus.com.ar/images/logo.png
</image>
<jwplayer:type>
sound
</jwplayer:type>
<jwplayer:duration>
14400
</jwplayer:duration>
</track>
<track>
<title>Libasoles radio</title>
<location>http://libasoles.no-ip.biz:8000/;*.nsv
</location>
<info>Prueba de emision</info>
<jwplayer:type>
sound
</jwplayer:type>
<jwplayer:duration>
-1
</jwplayer:duration>
</track>
</trackList>
</playlist>
Oct. 21, 2009hobbs
You can use a bit of JavaScript to switch streams if the stream can't connect.
<script type="text/javascript">
var player = null;
var playlist = null;
var currentTime = 0;
var previousTime = -1;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
playlist = player.getPlaylist();
if(playlist.length > 0)
{
player.addModelListener('TIME', 'timeMonitor');
checkTime();
}
else
{
setTimeout("addListeners();", 50);
}
};
function timeMonitor(obj)
{
currentTime = obj.position
};
function checkTime()
{
if(previousTime < currentTime)
{
previousTime = currentTime;
}
else
{
player.sendEvent('NEXT');
alert('Switching Streams');
}
setTimeout("checkTime();", 30000);
};
function gid(name)
{
return document.getElementById(name);
};
</script>
Oct. 21, 2009Guillermo Perez Farq
Thanks. This is the link between js and flash?
playlist = player.getPlaylist();
And, where is the call to the function? How should i call them?
Oct. 21, 2009hobbs
Just put the block of JavaScript code in the head element of your HTML document. Everything else is automatic.
If you want to change the delay before the stream switches, change the 30000.
If you don't want the alert, comment it out or delete it.
player = gid(obj.id);Gets the player reference object.
playerReady() Is called by the player after it is instantiated. The other functions are called as the code executes.
Oct. 21, 2009hobbs
Small improvement — add the code in bold.
<script type="text/javascript">
var player = null;
var playlist = null;
var currentTime = 0;
var previousTime = -1;
function playerReady(obj)
{
player = gid(obj.id);
addListeners();
};
function addListeners()
{
playlist = player.getPlaylist();
if(playlist.length > 0)
{
player.addModelListener('TIME', 'timeMonitor');
checkTime();
}
else
{
setTimeout("addListeners();", 50);
}
};
function timeMonitor(obj)
{
currentTime = obj.position
if(currentTime < previousTime)
{
previousTime = -1;
}
};
function checkTime()
{
if(previousTime < currentTime)
{
previousTime = currentTime;
}
else
{
player.sendEvent('NEXT');
alert('Switching Streams');
}
setTimeout("checkTime();", 30000);
};
function gid(name)
{
return document.getElementById(name);
};
</script>
Oct. 21, 2009Guillermo Perez Farq
Oh! Now it works!. Thank you so much.
I deactivate the alert because it jumps every second.
And i put the time out limit in 3000.
Many thanks.
Oct. 21, 2009Guillermo Perez Farq
mh... Well. it worked for a while.
Now i just get this on the server:
<10/21/09@22:47:16> [dest: 190.136.156.18] starting stream (UID: 85)[L: 8]{A: MPEG OVERRIDE}(P: 3)
<10/21/09@22:47:17> [dest: 190.136.156.18] connection closed (18 seconds) (UID: 78)[L: 7]{Bytes: 8192}(P: 0)
<10/21/09@22:47:20> [dest: 190.136.156.18] starting stream (UID: 86)[L: 8]{A: MPEG OVERRIDE}(P: 0)
<10/21/09@22:47:21> [dest: 190.136.156.18] connection closed (18 seconds) (UID: 79)[L: 7]{Bytes: 8192}(P: 4)
<10/21/09@22:47:22> [dest: 190.136.156.18] starting stream (UID: 87)[L: 8]{A: MPEG OVERRIDE}(P: 4)
<10/21/09@22:47:23> [dest: 190.136.156.18] connection closed (19 seconds) (UID: 80)[L: 7]{Bytes: 8192}(P: 6)
and the alerts may go on, but not the audio.
Oct. 21, 2009Guillermo Perez Farq
Actually, when i push play, several connections starts, and then they gets closed one by one.
But i think i hear the streaming the first time! And after that i just changed the transfer rate, but now i'm back to 32kbps.
What is this, please? What do i do wrong?
Oct. 21, 2009hobbs
Post a link to your Test Page and I'll have a look.
Here are your two streams and one from SomaFM.
http://willswonders.myip.org:8074/Simple_Shoutcast-10.html
Your streams seem to be quite flaky. I lose the connection quite often compared to the SomaFM stream.
It also takes a long time to connect to your streams, that's why I set the timeout at 30seconds.
Oct. 22, 2009Guillermo Perez Farq
Ah! ok. Maybe the switch just can't find so easily, so it switch once again and again.
I'm streaming from my own pc.
I just made a test file, and it works. But i can't test this on the original page because is already running for public.
Then it all work, but there's something in my original page that is causing the error: connect / disconnect.
But i just copied code to a new file and it worked. Mh...
Oct. 22, 2009Guillermo Perez Farq
Here it is: you can try it:
http://www.libasoles.com.ar/radio.php
Some time it connects, some others not.
Both radios are streaming right now.
Oct. 22, 2009lost
Your primary stream is working fine for me now. The player has never switched to the backup stream.
Oct. 22, 2009Guillermo Perez Farq
True. it only streams on daylight here.
We want to put another stream. And i'm streaming from my on pc (Libasoles), but sometimes i cannot reach that easy.
I 'd like to switch between radios but without autoplay. When i stop the radio (or pause it) the script switches an plays the other stream.
Oct. 22, 2009hobbs
I'll add some code to allow you to stop or pause the stream or manually switch streams without autoplaying.
Generally, if you click on another track or if you click on the previous/next buttons, the player assumes that you want to select AND play the previous/next track, so we have to stop the player if the index changes manually (not changed by the automatic stream switcher).
Oct. 22, 2009Guillermo Perez Farq
Thats it.
So, my stream is poor because of my modem. But switching the streams with this code is complete functional, except for the stop button issue.
Thanks.
Oct. 23, 2009IBRAHIM
I NEED SHOW ALL THIS
Oct. 23, 2009hobbs
@Guillermo,
I think it's working the way you want.
Try it here http://willswonders.myip.org:8074/Simple_Shoutcast-10.html
Oct. 26, 2009Guillermo Perez Farq
I'm not sure it's working as we were talking, but thanks for all anyway.
I mean, i think it's not switching anymore, so the autoplay can't be tested (when pressing pause or stop another radio used to start, remember?).
You wrote all this code from scratch? Wow.
I'd like to learn how to use js with jw player, so to add a var: "if none of my listed radios (one or two) is streaming, then hide the player".
Thanks @hobbs!
Oct. 26, 2009hobbs
You told me that you wanted the player to stay stopped when the user selected another track, so I added code to do just that, subverting the player's normal action of starting to play when another track was selected by the user. So now, after selecting another track, the user also has to click the play button to start the player.
I've tested it many times with your streams and it seems to automatically switch streams when yours fails.
Oct. 27, 2009mmj
hello
I've been struggling to get the setup for the following radio station: http://rs3.radiostreamer.com:9330/listen.pls
How do I have to set it up so I could listen to it using JW Player.
Thank you in advance for your help.
Oct. 27, 2009hobbs
@mmj,
1) Download listen.pls
2) Open listen.pls in a text editor.
3) Use the mountpoint URI in your player code.(If you're not using swfobject v2.2 to embed your Flash content, modify the code to the appropriate format for your embedding method.)
'file': 'http://207.200.96.230:8014/;*.nsv',
'type': 'sound',
If you go to the mount point with your browser, you can see that it is a Shoutcast stream, so you need to add ";*.nsv" to the URI.
Oct. 27, 2009mmj
Thanks for getting back to me:
this is what I have:
<script type='text/javascript' src='swfobject.js'></script>
<div id='mediaspace'>This text will be replaced</div>
<script type='text/javascript'>
var so = new SWFObject('player.swf','mpl','470','20','9');
so.addParam('allowfullscreen','false');
so.addParam('allowscriptaccess','always');
so.addParam('wmode','opaque');
so.addVariable('duration','3600');
so.addVariable('file','http://207.200.96.230:8014/;*.nsv');
so.addVariable('type', 'sound');
so.write('mediaspace');
</script>
I'm getting some music now but that's different from what when I'm listening to it in iTunes
Oct. 27, 2009hobbs
Maybe you didn't check YOUR listen.pls to get the correct mount point: http://rs3.radiostreamer.com:9330/
Oct. 28, 2009hobbs
@Guillermo,
Try the player again, I updated the code.
http://willswonders.myip.org:8074/Simple_Shoutcast-10.html
Nov. 04, 2009shoutcast help
Ive tried to make a new thread on here but I keep gettin an error, so sorry for hijacking another thread...
I run vbulletin and have used the Set-Up Wizard on here..
I uploaded the files into my forum root directory which is "radio" and made a folder for the plugin revolt which went into "playerplugins" .. this is the code the wizard left me with:
<embed
src='http://www.ibass-radio.com/radio/player-viral.swf'
width='800'
height='200'
bgcolor='undefined'
allowscriptaccess='always'
allowfullscreen='true'
flashvars='author=IBass-Radio.com&description=Live Djs Playing Best In House, Donk, Scouse, Hardcore, Trance, HardHouse, Electro & More Everynight!&file=http://81.19.209.202:8016/;*.nsv&link=http://www.ibass-radio.com/radio/&type=sound&backcolor=9999FF&frontcolor=FFFF99&lightcolor=00FF00&logo=http://www.ibass-radio.com/radio/logo_main.png&volume=50&plugins=playerplugins/revolt&autostart=true'
/>
When previewing the code and player on the Setup Wizard.. i get about under 1 second of sound before it stopping (so cant tell if the plugin works either)
When putting the embedded code onto my template on vbulletin .. the player shows...but doesnt play any music from the live stream and just shows the loading circle image animation thing ..
Any suggestions? . have i got the code right... are the files in right place..or is there something else ive missed?
Thanks for your help
Nov. 04, 2009shoutcast help
^^ addin to my above "shoutcast help" post ..
the live stream isn't on all the time, if anyone tests this they can change the port to "8600" that has a perminant stream on .. using the same IP ..
Thanks again
Nov. 04, 2009hobbs
Because of Adobe Flash Player security restrictions (accessing a stream at the binary level — blah, blah, blah), you can't use the spectrum visualizer plugins with anything but audio files served with HTTP progressive download.
No Shoutcast, no RTMP...
Nov. 17, 2009Guillermo Perez Farq
Here i'm still.
I think the first version of your switching radios system was the best (the simple one). But the button stop just doesn't work, because setTimeout(checkTime(),500) keeps on running and makes autoplay happend.
So i'm testing this, but it won't function. How should it be thne?
function checkTime(){
if(previousTime < currentTime) {
previousTime = currentTime;
}
else{
player.sendEvent('NEXT');
$(".bottom").effect("highlight", {"color":"blue"}, 2000);
}
setTimeout("checkTime();", 2000);
player.addControllerListener('STOP', 'basta');
};
function basta(){
player.sendEvent("STOP");
//player.sendEvent("PLAY","false");
}
I have a link here:
http://libasoles.com.ar/radio.php
Here are some helpful links to learn more about the JW Player™:
Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!
If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.