googleads / videojs-ima

IMA SDK Plugin for Video.js
Apache License 2.0
450 stars 284 forks source link

Can we force auto-play of video ads [muted] in IOS low power mode? #1074

Closed yashraj-02 closed 1 year ago

yashraj-02 commented 1 year ago

Can we force auto-play of video ads [muted] in IOS low power mode?

dioramayuanito commented 1 year ago

in iOS low power mode, video cannot be played unless user interact with the device. we can catch this scenario with 'suspend' event. https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/suspend_event

yashraj-02 commented 1 year ago

I have tried that. But unfortunately it didn’t work out. Do you have an example code that I can refer to?

yashraj-02 commented 1 year ago

@dioramayuanito

dioramayuanito commented 1 year ago

if 'signal' event cannot catch the scenario, you can use can-autoplay library to catch 'error' for autoplay-muted mode.

import canAutoPlay from 'can-autoplay';

canAutoPlay
    .video({timeout: 100, muted: true})
    .then(({result, error}) => {
        if(result === false){
            console.warn('Error did occur: ', error)
        }
    })

but still we cannot force autoplay in iOS low power mode.

Kiro705 commented 1 year ago

Hello @yashraj-02 ,

My understanding is that videos are not intended to autoplay in low-power mode. We recommend maintaining this behavior to respect to user's setting of low-power mode.

You can use the suspend event, mentioned in comment 2, to show a UI for starting the video, since auto-play is not an option in low-power mode.

Thank you, Jackson IMA SDK team