0

Hi all

Firstly may i say i have found your forums to be of great help, but I have a task and not entirely sure if its possible

I have a shoutcast radio that i have displaying on my shoutbox every 3.5 mins (auto refresh) but someone said what i need may be done with Javascript but hes as useless as me when it comes to Javascripts lol.

My friend said he thinks it may be possible to program the code i have to encorporate a onChange command that automatically when a song has finished and new one started & finished it recognises that the song has changed and runs the code i need to display the song in a shoutbox.

now heres the difficulty

Details are obtained via a xml file of which then a php code reads from this

i.e on my code $song[0] is the current one being played which auto changes this to $song[1] when its played.

is what i need possible? if you need copies of my file i would be more than happy to post.

Thanks in advance

3
Contributors
3
Replies
4
Views
6 Years
Discussion Span
Last Post by Airshow
0

You can in fact make a timer (= interval) that increments the variable 'play_time' every second, untill it reaches the end of the length of the song. Then it resets the play_time and load a new song. I am not sure how you play the song, so you need to incorporate that yourself:

var play_time = 0;
var current_song = 0;
var song_amount = 2;

var songs = new Array;

songs[0] = new Array;
songs[0]['length'] = 180; // In seconds
songs[0]['title'] = 'Song name0'; // Title of the song

songs[1] = new Array;
songs[1]['length'] = 230; // In seconds
songs[1]['title'] = 'Song name1'; // Title of the song

function HandleMusic() {

  if (play_time == songs[current_song]['length']) {

   /* Here you will have to place the code that plays the music.... */
   // Something like another function named PlaySong(song_id)

   /* Going to next song if it exists, else return to the first: */
   if (current_song != (song_amount - 1)) {
    current_song++;
   } else {
    current_song = 0;
   }

   /* Resetting play time: */
   play_time = 0;

  } else {

   /* Increasing play time: */
   play_time++;

  }
}

window.onload=function() {
setInterval(function(){
HandleMusic();
}, 1000);
}

~G

Edited by Graphix: n/a

0

thanks for the reply Graphix

ill have a look at what u have replied and see if i can use the reply into my code :S

AM

0

AcTw,

There are much easier ways to coordinate the playing of multiple sound files (and other multimedia) than to use JavaScript.

Personally, I would write and serve a Synchronized Multimedia Integration Language (SMIL) file. I can't recall all the details as I haven't used SMIL for some years now, but it is exactly the right thing for your problem.

Start here

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.