Click to See Complete Forum and Search --> : still learning...help!


LAwebTek
01-29-2003, 06:47 PM
I'm trying to do something a little unique and I'm sure it can be done because I'm already quite close. I'm trying to write a code that will first, look to see if the "continue" radio button is checked (that part works). Then it needs to check if the media's playState is == 1 (that part works, too). Here's where my code goes a little wacky -- I need it to advance to the next select option in the select list and play it after meeting the above conditions and auto select the option that is playing. My code does advance to and play the next song and even moves the selected focus to the item in the list, but afterward it just keeps playing the second item and doesn't continue down the list. Code is below, any thoughts??

//Continue() is called from "playSound()" which is
//called by the "play" button.

function Continue() {
if (document.cPlay.cButton[0].checked == true) {
playNext(); //if continuous play is checked, move on..
}
}

function playNext()
{
//playList is the form.select object
var playList = document.amp.playlist;
if (MediaPlayer.playState == 1) //if player is stopped
{
for(var i = 0; i < playList.options.length - 1; i++)
{
var next = playList.options[i].value;
MediaPlayer.URL = next; //song to play next
MediaPlayer.Controls.Play(); //Play current song
//make the current song the selected option
playList.options[i].selected = playList.options[i+1];
}
}
//if the playState is not 1 - keep checking..
setTimeout('Continue()',1000);
}

Please help!
Thanks - LAwebTek

LAwebTek
01-29-2003, 07:29 PM
ok, now I really don't get it. I had been testing the script by selecting the first sound in the list and then it would play the second sound and then repeat the second sound like three times. However, when I start playing from the 4th option it finishes playing and then scrolls to the last select option then from option 1 down to option 4 and plays option 4 again. I think this means I am not doing the incrementation method correctly but I must have tried 100 different ways already. Thanks for your time :)
LAwT

LAwebTek
01-29-2003, 07:38 PM
I have reposted the entire code in its current state of funkiness. It now requires Windows media Player 7 or greater though.

http://www.freecashjackpot.com/javaAMP/javaAMP.html

test it with some sytem sounds like "tada", "The Microsoft Sound" etc and you'll see what I mean about the strange behavior.

LAwebTek
01-29-2003, 07:52 PM
This has been a long experiment in learning and I thank you very much Dave for being a mentor during these last stages. Your solution worked perfectly and I'm pretty confident about coding the rest so this is a huge sigh of relief for me.