User Tools

Site Tools


vpfjsphp:playing_media_events
<ul class="player">
  <li data-src="audio/audio_1.mp3">audio 1</li>
  <li data-src="audio/audio_2.mp3">audio 2</li>
  <li data-src="audio/audio_3.mp3">audio 3</li>
</ul>

var jukebox = document.querySelector('ul.player');
jukebox.addEventListener('click', function(e) {
  var audio_player = document.createElement('audio');
  var piste = e.target.getAttribute('data-src');
  
  e.target.id = "playing";

  audio_player.id = "player";
  audio_player.src = piste;
  document.body.attachChild(audio_player);
  audio_player.play();
}, false);
vpfjsphp/playing_media_events.txt · Last modified: 2016/03/06 14:37 by leo