admin管理员组文章数量:1191171
Here's the description:
On iOS (iPhone or iPad) the following behaviour happens:
- when both an HTML video element and an HTML audio element are playing on a web page,
- and the video source ends,
- and the video source is programmatically forced to play again
then the system will automatically pause the audio.
See following stackblitz project for a sample:
.md
Its code is not really that much: most buttons work on both audio and video elements at once. When either audio or video notifies its end through an event, it is then programmatically rewound.
Steps to reproduce
Feel free to try with both another audio and video source, here limited by the available space in Stackblitz plan.
On an iPhone/iPad device or simulator, in Safari:
- browse to index.html
- when on iPhone, press iPhone Load to force preloading video. Not needed on iPad
- press Play to start playing both audio and video
- wait until clip ends and then restarts from 0:00
Expected
Audio should keep on playing and eventually loop.
Actual
When clip restarts from 0, audio is put to pause by the system.
Further details
This does not happen e.g. on Mac Safari nor on another device/browser. It also seems not strictly related to O.S. version: it happens both with iPadOS 17.x and iOS 18.x.
Also, some alternative scenarios:
- on HTML video end, if only play is invoked without resetting current time, the issue is still present
- on HTML video end, if only current time is reset without start playing it again, the issue disappears
- when HTML video element has the
muted
attribute, the issue disappears and audio is not paused - when HTML audio element is replaced with Web Audio API, the issue disappears and audio is not paused
I posted this question on Apple Developer forums, but I'm not really sure it'll receive a lot of feedback from there, being the topic not related to native apps.
This automatic behaviour comes kind of unexpected: it does not happen e.g. on MacOS, nor Android, now Windows. But maybe I am wrong: is this expected? And is there a way to avoid it?
本文标签: audioHTMLAudioElement on iOS is paused when video plays againStack Overflow
版权声明:本文标题:audio - HTMLAudioElement on iOS is paused when video plays again - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738406598a2085079.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论