0

How to change the playing speed of videos in HTML5? depicts a way of setting the playback speed of a html5 audio/video element, but the answers given in that question rely on the actual video/audio tag being present in the dom. The website - SoundCloud - in particular does not put the audio player in the DOM anywhere, but it still does use it internally. Since document.queryselector will not work, how can I set the playback rate?

micsthepick
  • 545
  • 5
  • 19

1 Answers1

0

You don't need to actually insert the audio tag into the DOM.

quick example here:

document.getElementById('play').addEventListener('click', event => {
    const audio = document.createElement('audio')
  audio.src = "https://www.w3schools.com/html/mov_bbb.mp4"
  audio.play()
})

https://jsfiddle.net/v4ma95L2/

Buntel
  • 426
  • 4
  • 13