Advanced Search

Results 1 to 4 of 4

Thread: JavaScript for window media player

  1. #1
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default JavaScript for window media player

    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!

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    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.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Dec 2006
    Location
    Raleigh, NC
    Posts
    15
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    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:

    Code:
    <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:

    Code:
    <?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)

  4. #4
    Join Date
    Dec 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by qeorge View Post
    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:

    Code:
    <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:

    Code:
    <?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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •