HTML5 Audio tag on Safari has a delay

后端 未结 9 642
無奈伤痛
無奈伤痛 2020-11-27 18:50

I\'m trying to accomplish a simple doodle-like behaviour, where a mp3/ogg sound rings on click, using the html tag. It is supposed to work under Firefox, Safari and Safari

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-11-27 19:01

    On desktop Safari, adding AudioContext fixes the issue:

    const AudioContext = window.AudioContext || window.webkitAudioContext;
    const audioCtx = new AudioContext();
    

    I found out by accident, so I have no idea why it works, but this removed the delay on my app.

提交回复
热议问题