PDA

View Full Version : JavaScript for window media player



ishtar
12-29-2006, 05:07 PM
Hi everyone,
At this wonderful website, Iím searching for a javascript, that will help me reach my goal.
OK look hereís the details:
I have an online radio at my website (www.metalsuriname.com), to play music, I just simply insert a playlist and it plays the music, BUT on every Thursday night here on a local radio, thereís a show, and I want to stream that show, BUT I donít always want to change the url manually, because I might not always get the chance.

Now my question is:
Is there a script based on UTC time or something which can change the url (or player) automatic for me?

I hope there is oneÖ.


Thank you in advance, and a happy new year to everyone here!

thetestingsite
12-29-2006, 05:15 PM
You could use PHP's date function (http://php.net/date) to achieve this. Just take a look at a few of the examples on the page and that should help you out, if not, let me know and I'll try to help out as much as I can.

Hope this helps.

qeorge
12-29-2006, 06:10 PM
I took a quick peek at the site, which is cool BTW. It seems to me that in the popup where you play the radio, you are simply setting the src attribute to an mp3 file:


<embed type="application/x-mplayer2" src="http://www.metalsuriname.com/mp3/02.%20Follow%20The%20Way.mp3" name="mediaPlayer" id="mediaPlayer" height="50px" width="280px" showControls="1"></embed>

Not sure what you mean by inserting a playlist.

It would be relatively easy to change this so that the src attribute is provided by a PHP script. To do so, one would put PHP code at the top of the page and in the embed tag:



<?php
// date('w') returns the weekday, 0-6 (6 == Sunday)
// date('H') returns the hour, 0-23 (0 == midnight, 23 == 11 PM)
if (date('w') == 4 && date('H') == 21)
{
$mp3Url = 'radio_show.mp3';
}
else
{
$mp3Url = 'normal_song.mp3';
}
?>


//html here.....


<embed type="application/x-mplayer2" src="<?php echo $mp3Url; ?>" name="mediaPlayer" id="mediaPlayer" height="50px" width="280px" showControls="1"></embed>

// rest of html here



Save the file as .php, and give it a shot. I'd love to hear how it goes.

(Note: there are many better means to do this, like AJAX, but this is an extremely simple solution)

ishtar
01-02-2007, 01:40 PM
I took a quick peek at the site, which is cool BTW. It seems to me that in the popup where you play the radio, you are simply setting the src attribute to an mp3 file:


<embed type="application/x-mplayer2" src="http://www.metalsuriname.com/mp3/02.%20Follow%20The%20Way.mp3" name="mediaPlayer" id="mediaPlayer" height="50px" width="280px" showControls="1"></embed>

Not sure what you mean by inserting a playlist.

It would be relatively easy to change this so that the src attribute is provided by a PHP script. To do so, one would put PHP code at the top of the page and in the embed tag:



<?php
// date('w') returns the weekday, 0-6 (6 == Sunday)
// date('H') returns the hour, 0-23 (0 == midnight, 23 == 11 PM)
if (date('w') == 4 && date('H') == 21)
{
$mp3Url = 'radio_show.mp3';
}
else
{
$mp3Url = 'normal_song.mp3';
}
?>


//html here.....


<embed type="application/x-mplayer2" src="<?php echo $mp3Url; ?>" name="mediaPlayer" id="mediaPlayer" height="50px" width="280px" showControls="1"></embed>

// rest of html here



Save the file as .php, and give it a shot. I'd love to hear how it goes.

(Note: there are many better means to do this, like AJAX, but this is an extremely simple solution)




hey, THANK u, i tried it, and it works :D