mostly filebased Content Presentation System
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

60 lines
1.3KB

  1. function AudioTagSample() {
  2. // initialize audio player
  3. this.audio = new Audio();
  4. this.isPlaying = false;
  5. window.addEventListener('load', this.onload.bind(this), false);
  6. }
  7. AudioTagSample.prototype.onload = function() {
  8. // Create the audio nodes.
  9. this.source = context.createMediaElementSource(this.audio);
  10. this.source.connect(context.destination);
  11. };
  12. AudioTagSample.prototype.click = function(link) {
  13. var was_inactive = this.audio.paused
  14. var was_the_same = this.audio.src == link.href
  15. var controls = document.querySelectorAll('.controls');
  16. for (i=0;i<controls.length;i++){
  17. controls[i].classList.toggle("playing");
  18. controls[i].classList.remove("fresh");
  19. };
  20. if (was_the_same) {
  21. if (this.audio.paused) {
  22. this.audio.play();
  23. link.classList.remove("paused")
  24. link.classList.add("playing")
  25. } else {
  26. this.audio.pause();
  27. link.classList.remove("playing")
  28. link.classList.add("paused")
  29. }
  30. } else {
  31. if(this.link) {
  32. this.link.classList.remove("playing")
  33. this.link.classList.remove("paused")
  34. }
  35. this.audio.src = link.href;
  36. this.link = link
  37. this.audio.play();
  38. link.classList.remove("paused")
  39. link.classList.add("playing")
  40. }
  41. if (was_inactive) {
  42. requestAnimFrame(this.draw.bind(this));
  43. }
  44. this.link = link;
  45. };