Developer forum

Forum » Swift » Auto play not working on Iphones

Auto play not working on Iphones

Alexander Tømmerholen
Reply

Hello,
For one of our customers we are using the itemtype "Media" on the productpage. We are displaying both images and videos. This work fine everywhere expect on Iphones. The videos will not start automatically as it does everywhere else. 

We are running on Swift 1.26.2 and I have checked all the releaselog and i can not see that this has been a bug that has been fixed in later version of Swift. 


Replies

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Alexander

I do not think it is a DW or Swift issue. Can you share the actual and precise rendered markup? There can be subtle things causing 

Things that can cause videos to not autoplay on iOS:

  • iOS 'Battery saver' is on - will prevent autoplay videos
  • 'Wrong' mp4 codec - or webm files. The video has to be encoded to meet some Safari standards. Try uploading the video to Vimeo or Youtube to see if that fixes the issue
  • Video-tag is missing 'muted' and 'playsinline' attributes (these are standard Swift)

BR Nicolai

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

Hi Alexander

I do not think it is a DW or Swift issue. Can you share the actual and precise rendered markup? There can be subtle things causing 

Things that can cause videos to not autoplay on iOS:

  • iOS 'Battery saver' is on - will prevent autoplay videos
  • 'Wrong' mp4 codec - or webm files. The video has to be encoded to meet some Safari standards. Try uploading the video to Vimeo or Youtube to see if that fixes the issue
  • Video-tag is missing 'muted' and 'playsinline' attributes (these are standard Swift)

BR Nicolai

 
Alexander Tømmerholen
Reply

Hi Nicolai,

We are using the standard template "Swift_ProductDetailsImage.cshtml" which again are using "Components/VideoPlayer.cshtml". We have not changed anything in these templates, beside updating these two files from newer swift versions. They output the following code:

Code inside "#document"

Feel free to check out the code with inspect tool here if you want :)

Im guessing that "plyr" is a thrid party solution used by Swift. 

 
Nicolai Pedersen Dynamicweb Employee
Nicolai Pedersen
Reply

iOS really do not want autoplay to happen - especially on things not in viewport and with sound.

It has to be a muted video for once. Since this is a Youtube, for the embed URL try adding the mute option or add &muted=1 to the embed URL.

 
Alexander Tømmerholen
Reply

I was able to make it work with doing a few changes inside of "VideoPlayer.cshtml".

Removed "iosNative: true" and added "player.config.playsinline = false"

 

You must be logged in to post in the forum