How to change the playing speed of videos in HTML5?描述了一种设置html5音频/视频元素的播放速度的方法,但是该问题中给出的答案取决于dom中存在的实际视频/音频标签。特别是SoundCloud网站,虽然没有将音频播放器放置在DOM中的任何位置,但仍在内部使用它。由于document.queryselector无法正常工作,如何设置播放速率?
您实际上不需要将音频标签插入DOM。
此处为快速示例:
document.getElementById('play').addEventListener('click', event => {
const audio = document.createElement('audio')
audio.src = "https://www.w3schools.com/html/mov_bbb.mp4"
audio.play()
})