Zarifus Posted February 19, 2006 Share Posted February 19, 2006 Ok, I have created a page with music playing in the background, and a button that will let me change the music by cycling through an array that lists out different songs.Can I make the player automatically change to the next song once the first one is done playing? (Like an event?)The Quicktime Plugin: <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="320" height="256" id="mediaplayer"> <param name="src" value="web-content/music/Meteor.mov"> <embed height=256 width=320 src="web-content/music/Meteor.mp3" type="video/quicktime" pluginspage="web-content/www.apple.com/quicktime/download" enablejavascript="true" / name="mediaplayer" /> </object> The function that changes to the next song <script> var songnum = 0 var songarr=new Array() songarr[0]="Meteor.mp3"; songarr[1]="Invoke.mp3"; songarr[2]="Thunderbird.mp3"; songarr[3]="Vestige.mp3"; songarr[4]="Zips.mp3"; function NextIt(anObj) { songnum++; if(songnum>4) { songnum=0 } anObj.SetURL(songarr[songnum]); } </script> What I use to call the function (from the button) href="javascript:NextIt(document.mediaplayer);" What I'm hoping for is an event that could trigger the NextIt function.Thanks! (I'm new here, just starting with Javascript. Took out some books from the library nearby ) Link to comment Share on other sites More sharing options...
scott100 Posted February 19, 2006 Share Posted February 19, 2006 Try using a setTimout() function, call it after one song has finished playing. It should be explained in your book.Also see this similar post: http://w3schools.invisionzone.com/index.php?showtopic=2286 Link to comment Share on other sites More sharing options...
Zarifus Posted February 20, 2006 Author Share Posted February 20, 2006 Thanks for the reply!The setTimeout() function would be useful, but I don't think it will work in my case, mainly because I have a 'Next Song' button, meaning that visitors can manually change the song, which would throw off of the timings...Hmm.... wait, can I cancel a previous timeout function? Link to comment Share on other sites More sharing options...
Zarifus Posted March 2, 2006 Author Share Posted March 2, 2006 Ok, I've figured out most of the stuff I need now, like how to cancel the timeouts. One last thing I need to know though. Is there a way to get it to return the amount of time left in the timer?For instance, if I started a 30 second timer, but canceled it when it still had 13 seconds left, can I get it to return the value 13?I need this in order to make it move to the next song properly even after someone uses the Pause and Play button.Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now