BrU32

JS Web Audio API Playback Audio At Various Speed's SRC

Jul 29th, 2016
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. <button id="m1" min="0.1" max="1.5" value="1.0" onclick="a.playbackRate=m1.value++;">Slow It DOwn!!</button>
  2. <button id="m2" min="0.1" max="1.5" value="1.0" onclick="a.playbackRate=m2.value--;">Slow It DOwn!!</button>
  3. <audio type="audio/mpeg" id="aud" src="http://compulsivecoding.com/DJ%20BrU%20-%20The%20Influx.mp3" autoplay="false"><audio/>
  4. <script>
  5. var audioCtx = new AudioContext();
  6. var oscillator=audioCtx.createGainNode();
  7. oscillator.connect(audiotCtx.destination);
  8. audioCtx.connect(oscillator.gain)
  9. aud.play(aud);
  10. </script>
  11.  
  12. <script>
  13. var a = document.getElementById("aud");
  14.  
  15. function getPlaySpeed() {
  16. alert(a.playbackRate);
  17. }
  18.  
  19. document.onclick=function setPlaySpeed(value) {
  20. a.playbackRate = value;
  21. }
  22. setPlaySpeed(0.5);
  23. oscillator.gain.value='0.3';
  24. </script>
  25.  
  26. </body>
  27. </html>
Advertisement
Add Comment
Please, Sign In to add comment