Problem music player JavaScript

willemvo

New Member
Messages
19
Reaction score
0
Points
0
Hello js-experts...
I have a quetion for you i've been busy days and days but can't find the answer to play the music,, can somebody please tell me how to fix it or fix it for me?? here's the code
Code:
<html>
<head>
<script type="text/javascript">
<!-- 
counter = 0;
songs = new Array();

function addsong() {
 file = document.forms[0].file.value;
 if(file == "") {
 alert("Choose a sound.\rPress the button bladeren...");
}
 else {
  fn = file;
  while(fn.indexOf() != -1) {
   pos = fn.indexOf();
   fn = fn.substring(fn.lenght);
  }
 songs[counter] = file;
 document.forms[0].Liste[counter] = new Option(fn, file, false, true);
 counter++;
 document.forms[0].file.value = "";
 }
}

function music() {
 document.all.sound.src=document.Form.Liste.options[document.Form.Liste.selectedIndex].text;
}

function stop() {
 document.all.sound.src="";
}

function count() {
 document.Form.songs.value=document.Form.Liste.options.length;
}

function deletethis() {
 if(counter > 0) {
  counter--;
  document.forms[0].Liste[counter] = null;
  songs[counter] = "";
 }
 else {
 alert("There are no files found \rto delete from the Playlist!");
 }
}

function nach_unten() {
 var al = document.Form.Liste.options.length; al -= 1;
 if(document.Form.Liste.selectedIndex < al){
  document.Form.Liste.options[document.Form.Liste.selectedIndex++];
  adresse();
 }
}

function nach_oben() {
 if(document.Form.Liste.options[0].selected != true){
  document.Form.Liste.options[document.Form.Liste.selectedIndex--];
  adresse();
 }
}

function adresse() {
 fn = document.Form.Liste.options[document.Form.Liste.selectedIndex].text;
 chare = unescape("%5C");
 while(fn.indexOf(chare) != -1) {
  pos = fn.indexOf(chare);
  fn = fn.substring(pos + 1, fn.length);
  document.Form.name2.value=fn;
  }
}
// -->
</script>

</head>
<body onLoad="count()" onClick="count()"><bgsound name="sound" id="sound" src="">
<form name="Form">
<table align=center cellpadding="5" cellspacing="0" bgcolor="#EFEFEF">
 <tr>
  <td><b>
    <input type=file name=file size=21>     
    <input type=button value="Toevoegen" onClick="addsong(); adresse()">    
    <input type="button" value="Verwijderen" onClick="deletethis(); document.Form.name2.value=''">
    <br><br>
    <input type="text" name="name2" value="" size="47" style="color: #FF0000" readonly>    
    
    <input type="button" value=" \/ " onClick="nach_unten()">
    <input type="button" value=" /\ " onClick="nach_oben()">   
    <input type="button" name="empezar" value=" Play" onClick="if(document.Form.songs.value> 0){adresse(); music()}">  
    <input type="button" name="detener" value="Stop" onClick="stop()">
    <br>
    <select name=Liste size=10 style="width: 500px; font-size: 9px; color: #0000CC" onClick="if(document.Form.songs.value > 0){adresse(); music()}"></select><br>
    </b>You're having: <input type="text" name="songs" size="1" readonly>file(s) in
   your Playlist.
  </td>
 </tr>
</table>
</form>

</body>
</html>
Thanks!!;)
 

scopey

New Member
Messages
62
Reaction score
0
Points
0
If you havn't already, I find that the best way to debug my JS is to use Firefox and the extension 'Firebug'. You can insert breakpoints in your JS script where it stops and gives you details of what your script has done so far, plus it gives you extensive error messages. Makes js much easier. I've had a quick look through the code and can't see anything major. When I have more time I'll take a closer look for you.
 

willemvo

New Member
Messages
19
Reaction score
0
Points
0
Thanks scopey;) please make some time if you can
thanks in advance:biggrin:
 

scopey

New Member
Messages
62
Reaction score
0
Points
0
If you have a link to the page where the script is used, that'd make it easier :p .
 

willemvo

New Member
Messages
19
Reaction score
0
Points
0
sorry but my site is still off-line!!:happysad:
but you can just put it in notepad++ or something, and save it as file.html!!:biggrin:
 
Top