Question About Adding Music to a Page

Got a little techonology problem that you need fixed pronto? Post it here and we'll see what we can do.

Moderator: Moderators

Locked
Message
Author
Starchaser
Honorary Member
Honorary Member
Posts: 886
Joined: Mon May 31, 2004 7:03 am
Location: Los Angeles, CA

Question About Adding Music to a Page

#1 Post by Starchaser »

Hi, just a quick little question, and I'd appreciate any help.

Currently, I'm working on customizing my LiveJournal. I know that there are codes to add music to a page in HTML or CSS or whatever, and I know that you can make one song play infinitely. However, I was wondering if it was possible to play a few songs in a loop, something like this:

Song 1
Song 2
Song 3
Song 4
Song 1 again
etc.

Is there any codes to do this, and if so will you let me know what they are? Thanks! :D
Image
Hunter Lupe
Administrator
Administrator
Posts: 1140
Joined: Mon May 31, 2004 1:36 pm
Contact:

#2 Post by Hunter Lupe »

Try using a media player control with a playlist.

I don't think you can do this with bgsound.
Image
Will you stop with the honour stuff?
stoodder
Honorary Member
Honorary Member
Posts: 169
Joined: Sat Jun 05, 2004 6:30 pm
Location: Milwaukee, Wisconsin
Contact:

#3 Post by stoodder »

hmm good one, i knwo theres a way to do it try looking into some javascript, a couple tips:

maybe somehting like document.bgsound="thesound";

whihc might set the sound but dont count on it becaus eim only guessing

what iw ould do is make a function that recurse after a song is done, you might have to se tthe length of a song, ill look more into it for ya
Hunter Lupe
Administrator
Administrator
Posts: 1140
Joined: Mon May 31, 2004 1:36 pm
Contact:

#4 Post by Hunter Lupe »

That's another way to do it. If you setTimeout(handlerfunction, songlength*1000), you'll know when to set the next one.

Assuming document.bgsound is valid, you would use:

Code: Select all

<script>
var songs = Array("sound1.mid","sound2.mid","sound3.mid"); //Filenames
var slength = Array(67,23,43); //Duration in seconds
var song_id = 0; //Start ID

nextSong();

function nextSong() {
 document.bgsound = songs[song_id];
 setTimeout ("nextSong();",slength[song_id]*1000);
 song_id++;
 if (song_id > songs.length) song_id = 0;
}
</script>
Image
Will you stop with the honour stuff?
Locked