Advertisement
rdsedmundo

Play all audios on wiki page

Feb 27th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (() => {
  2.   const audios = $('.sm2_button');
  3.  
  4.   function playAudio(index) {
  5.      if (index === audios.length) return;
  6.  
  7.      const audio = new Audio();
  8.  
  9.      audio.src = audios.eq(index).attr('href');
  10.  
  11.      audio.addEventListener('loadeddata', () => {
  12.        audio.play();
  13.      });
  14.  
  15.      audio.addEventListener('ended', () => {
  16.        setTimeout(() => playAudio(index + 2), 2000);
  17.      });
  18.   }
  19.  
  20.   playAudio(0);
  21. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement