Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

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

javascript - Force autoplay video to continue when switching tabs on iOS

I have an HTML5 video tag with the attributes autoplay loop muted playsinline. In iOS the video stops playing, if the user switches to another browser tab. However it doesn't start again when switching back.

I tried listening for different events such as window.onfocus() and then manually starting the video with the play() method, however these events do not seem to fire, until the user actually clicks inside the document again, and so they are virtually useless in this case.

This site has an HTML5 video tag in the hero: https://www.stoxenergy.com/en/technology/ However that one keeps playing, even when the user switches tabs.

I can't figure out how they do it. Any ideas?


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

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share
...