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?
Asked
Active
Viewed 677 times
1 Answers
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()
})

Buntel
- 540
- 6
- 19
-
is there a way of finding it again, if it isn't part of the DOM though? – micsthepick May 04 '20 at 01:28
-
You have to save a reference for later usage I guess. – Buntel May 04 '20 at 01:31