2013-05-14 2 views
0

님, 내 Rails 앱에서 audio.js 플러그인을 사용하고 있습니다. Audio.js의 API로 재생 목록을 만들 수는 있지만 문서를 찾지 못했습니다. 그렇다면 audio.js 또는 다른 js 오디오 플러그인으로 재생 목록을 구현하려면 어떻게해야합니까? audio.js를 재생 목록과 함께 사용하는 예가 있지만 구현 방법을 이해할 수 없습니다. 당신은 상단에있는 스크립트 태그의 내부 페이지의 소스를 보면 http://kolber.github.io/audiojs/demos/test6.html재생 목록이있는 자바 스크립트 오디오

답변

3

당신이 URL에 데이터 SRC에서 URL을로드 볼 수 있듯이

<script> 
     $(function() { 
     // Setup the player to autoplay the next track 
     var a = audiojs.createAll({ 
      trackEnded: function() { 
      var next = $('ol li.playing').next(); 
      if (!next.length) next = $('ol li').first(); 
      next.addClass('playing').siblings().removeClass('playing'); 
      audio.load($('a', next).attr('data-src')); 
      audio.play(); 
      } 
     }); 

     // Load in the first track 
     var audio = a[0]; 
      first = $('ol a').attr('data-src'); 
     $('ol li').first().addClass('playing'); 
     audio.load(first); 

     // Load in a track on click 
     $('ol li').click(function(e) { 
      e.preventDefault(); 
      $(this).addClass('playing').siblings().removeClass('playing'); 
      audio.load($('a', this).attr('data-src')); 
      audio.play(); 
     }); 
     // Keyboard shortcuts 
     $(document).keydown(function(e) { 
      var unicode = e.charCode ? e.charCode : e.keyCode; 
      // right arrow 
      if (unicode == 39) { 
      var next = $('li.playing').next(); 
      if (!next.length) next = $('ol li').first(); 
      next.click(); 
      // back arrow 
      } else if (unicode == 37) { 
      var prev = $('li.playing').prev(); 
      if (!prev.length) prev = $('ol li').last(); 
      prev.click(); 
      // spacebar 
      } else if (unicode == 32) { 
      audio.playPause(); 
      } 
     }) 
     }); 
    </script> 

<li><a href="#" data-src="http://s3.amazonaws.com/audiojs/01-dead-wrong-intro.mp3">dead wrong intro</a></li> 

비슷한 작업을 수행하십시오.

관련 문제