liqvidjs / liqvid

Library for interactive videos in React
https://liqvidjs.org
MIT License
754 stars 39 forks source link

Player pauses when trying to play Video in iOS #36

Open anishg-cn opened 1 year ago

anishg-cn commented 1 year ago

The scenario is, there is a Video element which starts at, let's say, 5 second. So, the video plays fine for 5 seconds and suddenly it pauses and never starts again, until manually played again.

This happens in iOS Chrome (and maybe Safari as well).

I think the issue might be the following: image

@ysulyma can you please let me know how to fix this?

ysulyma commented 1 year ago

I'll take a look!

anishg-cn commented 1 year ago

@ysulyma did you get time to look into the issue? it would be very helpful if you could check the issue as fast as possible.

ysulyma commented 1 year ago

@anishg-cn not yet, will attempt to fix tomorrow evening

ysulyma commented 1 year ago

@anishg-cn does your video have audio? If so, it is impossible to have it start playing without a user interaction (e.g. clicking), due to the Web Autoplay Policy. The recommended solution is to remove the audio track from the video and merge it with whatever <Audio> you're using (which should start at 0:00).

anishg-cn commented 1 year ago

@ysulyma but it works in android and pc, only issue in iOS?

anishg-cn commented 1 year ago

@ysulyma also user interacts by clicking the play button in the player, so shouldn't it work after that?

ysulyma commented 1 year ago

@anishg-cn

Also note iOS can only play one channel of audio at a time so you'd need to do the audio extraction trick anyway. It may be possible to work around this using the Web Audio API, however that is complex and I haven't tried it yet. See the following: