943,175 Members | Top Members by Rank

Ad:
Aug 29th, 2010
0

javascript web music player control

Expand Post »
I am trying to create a music web player that changes song automatically, however the song is instead repeated and whenever next is click, and some codes are executed to stop the current song and start the next, the current song pauses for about 1 sec instead... can some please tell me how to solve these issues? oh, if i remove the "//alert("song is about to play"); line, the song only plays for about a sec and stop.

Here is the code:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script type="text/javascript">
  2. function cselector(ctype)
  3. {
  4. num=1;
  5. for(count=num;count<10;count++){
  6. //alert("cselector selected="+ctype);
  7. //alert(count);
  8. switch(num){
  9. case 1:
  10. content=document.getElementsByTagName("audio")[0];
  11. //test=content.duration;
  12. //alert(test);
  13. op(ctype,content,count);
  14. break;
  15. case 2:
  16. content=document.getElementsByTagName("audio")[1];
  17. op(ctype,content,count);
  18. test=content.duration;
  19. alert(test);
  20. break;
  21. case 3:
  22. content=document.getElementsByTagName("audio")[2];
  23. op(ctype,content,count);
  24. test=content.duration;
  25. alert(test);
  26. break;
  27. case 4:
  28. content=document.getElementsByTagName("audio")[3];
  29. op(ctype,content);
  30. break;
  31. case 5:
  32. content=document.getElementsByTagName("audio")[4];
  33. op(ctype,content);
  34. break;
  35. case 6:
  36. content=document.getElementsByTagName("audio")[5];
  37. op(ctype,content);
  38. break;
  39. case 7:
  40. content=document.getElementsByTagName("audio")[6];
  41. op(ctype,content);
  42. break;
  43. case 8:
  44. content=document.getElementsByTagName("audio")[7];
  45. test=content.duration;
  46. alert(test);
  47. op(ctype,content);
  48. break;
  49. case 9:
  50. content=document.getElementsByTagName("audio")[8];
  51. op(ctype,content);
  52. break;
  53. case 10:
  54. content=document.getElementsByTagName("audio")[9];
  55. op(ctype,content);
  56. break;
  57. }
  58. }
  59. }
  60.  
  61.  
  62. function op(ctype,content,count)
  63. {
  64. //alert("parameters pushed:",+ctype+content);
  65. //count=0;
  66. while(count<10){
  67. switch(ctype){
  68. case 1:
  69. //alert("content about to be played");
  70. content.play();
  71. break;
  72. case 2:
  73. //alert("content about to be paused");
  74. content.pause();
  75. break;
  76. case 3:
  77. content.pause();
  78. atend=content.duration;
  79. content.currentTime(atend);
  80. next(count);
  81. break;
  82. case 4:
  83. //
  84. break;
  85. }
  86. }
  87. }
  88.  
  89. function next(i)
  90. {
  91. var song=document.getElementsByTagName("audio")[i];
  92. var num=i+1;
  93. var song=document.getElementsByTagName("audio")[num];
  94. op(1,song,num);
  95. }
  96.  
  97. </script>
  98.  
  99. /*piece of html*/
  100. <div class="btn" onclick="cselector(1)">PLAY</div>
  101. <div class="btn" onclick="cselector(2)">PAUSE</div>
  102. <div class="btn" id="nextbtn" onclick="cselector(3)">NEXT</div>
  103. <div class="btn">PREVIOUS</div>
Reputation Points: 10
Solved Threads: 0
Newbie Poster
koykemar is offline Offline
1 posts
since Dec 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: how to write this kind of xpath exprssion?
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: Jquery validator - rules with 2 conditions





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC