On iOS (iPhone or iPad) the following behaviour happens:
- when both an HTML video element and an HTML audio element are playing on a 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:
https://stackblitz.com/edit/ios-audio-paused-on-video-playing?file=README.md
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.
Also, some alternative scenarios:
- when HTML video element has the
muted
attribute, the issue disappears and audio is not paused - when HTML audio element is replace with Web Audio API, the issue disappears and audio is not paused