Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
481 views
in Technique[技术] by (71.8m points)

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

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.

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...