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

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


This is the outline:

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

  • when each an HTML video ingredient and an HTML audio ingredient are taking part in on an internet web page,
  • and the video supply ends,
  • and the video supply is programmatically compelled to play once more

then the system will mechanically pause the audio.

See following stackblitz venture for a pattern:

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

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

Steps to breed

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

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

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

Anticipated

Audio ought to carry on taking part in 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 machine/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 situations:

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

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

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
rooshohttps://www.roosho.com
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here


Latest Articles

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog.