javascript - Html5 audio playlist not working -


i have audio html5 player, since working fine on single audio when adding more audios :

  1. pitbull
  2. shakira
  3. bilal saeed

now, click on pitbull (ok working fine) when click on (bilal saeed or shakira) song song playing instead of, pause pitbull , start shakira or bilal saeed.
check on jsfiddle

html

<div id="playlist">     <a href="#">         <span class="glyphicon glyphicon-play-circle">             <audio preload='none'>                 <source src='http://freshly-ground.com/data/audio/mpc/20090119%20-%20untitled%20groove.mp3' type='audio/mpeg' />             </audio>         </span>     </a>     <a href="#">         <span class="glyphicon glyphicon-play-circle">             <audio preload='none'>                 <source src='http://audio.khanqah.org/ak20021104%20rozay%20or%20taqwa%20may%20rabt.mp3' type='audio/mpeg' />             </audio>         </span>     </a>     <a href="#">         <span class="glyphicon glyphicon-play-circle">             <audio preload='none'>                 <source src='http://audio.khanqah.org/ak19991224%20tark%20e%20masiat%20may%20takheer%20na%20kijiay.mp3' type='audio/mpeg' />             </audio>         </span>     </a> </div> 

js

document.getelementbyid('playlist').addeventlistener('click', function(e){     var target = e.target;     if(target && target.nodename === 'span'){         if(target.classname == "glyphicon glyphicon-play-circle"){             target.childnodes[1]['play']();             target.classname = "glyphicon glyphicon-pause"         }else{             target.childnodes[1]['pause']();             target.classname = "glyphicon glyphicon-play-circle"         }     } }); 


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -