9.5 C
New York
Tuesday, March 11, 2025

audio – HTMLAudioElement on iOS is paused when video performs once more


Here is the outline:

On iOS (iPhone or iPad) the next behaviour occurs:

  • when each an HTML video factor and an HTML audio factor are enjoying on an online web page,
  • and the video supply ends,
  • and the video supply is programmatically pressured to play once more

then the system will routinely pause the audio.

See following stackblitz undertaking for a pattern:

https://stackblitz.com/edit/ios-audio-paused-on-video-playing?file=README.md

Its code isn’t actually that a lot: most buttons work on each audio and video components directly. When both audio or video notifies its finish by way of an occasion, it’s then programmatically rewound.

Steps to breed

Be happy to attempt with each one other audio and video supply, right here restricted by the out there house in Stackblitz plan.

On an iPhone/iPad gadget or simulator, in Safari:

  1. browse to index.html
  2. when on iPhone, press iPhone Load to pressure preloading video. Not wanted on iPad
  3. press Play to start out enjoying each audio and video
  4. wait till clip ends after which restarts from 0:00

Anticipated

Audio ought to carry on enjoying and finally loop.

Precise

When clip restarts from 0, audio is put to pause by the system.

This doesn’t occur e.g. on Mac Safari nor on one other gadget/browser. It additionally appears not strictly associated to O.S. model: it occurs each with iPadOS 17.x and iOS 18.x.
Additionally, some various eventualities:

  • on HTML video finish, if solely play is invoked with out resetting present time, the difficulty remains to be current
  • on HTML video finish, if solely present time is reset with out begin enjoying it once more, the difficulty disappears
  • when HTML video factor has the muted attribute, the difficulty disappears and audio isn’t paused
  • when HTML audio factor is changed with Net Audio API, the difficulty disappears and audio isn’t paused

I posted this query on Apple Developer boards, however I am not likely certain it will obtain numerous suggestions from there, being the subject not associated to native apps.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles