Mobile Safari skips first seconds of HTML Audio on play()

狂风中的少年 提交于 2021-02-08 15:12:35

问题


I have an React Audio Player that uses a useAudio hook to manage the HTML5 audio. It works fine everywhere except Mobile Safari, where the sound begins a few seconds after the player starts playing.

What's odd is that I'm checking canplaythrough on the element before calling HTMLAudioElement.play(). So Safari fires canplaythrough and starts "playing" the audio, except that the audio doesn't actually start until a second or so in.

Here's a complete example on CodeSandbox: https://codesandbox.io/s/useaudioplayer-jvftw?file=/src/useAudio.tsx

To replicate, open in Mobile Safari and play the Audio.

来源:https://stackoverflow.com/questions/65952427/mobile-safari-skips-first-seconds-of-html-audio-on-play

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!