Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Initial-user-action requirement on mobile


I'm a dev at an ad-tech company that is developing an HTML5/JavaScript VPAID wrapper for video ads.

On desktop, we pretty much have everything working.

On mobile, however, we can't seem to get around the "initial user action" requirement. The problem is this: our wrapper doesn't even load on the page until the user clicks "play" in JW player. The reasons for this are many, not the least of which is that we need environmentVars passed to initAd in order to know where to render the ad node, and in order to establish a link to the video player which may even be cross-domain to where our script is injected (in which case we couldn't wire events to its controls even if we wanted to).

In other words, we do not "own" the video player. We're a VPAID wrapper which should work with any HTML5 VPAID compliant player, including JW.

So, long story short, if on initAd we attach a "touchstart" (or similar) event to the adSlot, and then call initialization code when that event is triggered, the ad does play. In practice, this basically looks like this: the user clicks "play", the player shows a spinner with "loading ad" -- and if the user touches the player (the adSlot, rather) within the default 15-second timeout, the ad plays.

Obviously, we cannot require the user to do this in the real world.

If, however, I try to trigger the event programmatically -- I've tried both touch and mouse events -- things seem normal until adsManager_.start() is called. Then, the player seems to display the first frame of the ad but it fails to play it further. 15 seconds later, we get a timeout.

So basically, our VPAID wrapper script doesn't even load on the page until the user clicks "play" in JW player. Once our script loads, we cannot require the user to issue yet another "real" physical event. We want the ad to play when our script loads without requiring another physical user action.

Any way around this?

Thanks in advance!


3 Community Answers

Eric Boyd

JW Player Support Agent  
0 rated :

Hi Slavko,
Our Lead Engineer responded to your post on the forum you posted on with Google.!topic/ima-sdk/89AJq3CIMG8



0 rated :

this seems to be close to the issue i am having with pre-roll video ads on Android, with the mobile sdk. Especially this part of the answer: "You will get a warning such as Failed to execute 'play' on 'HTMLMediaElement': API can only be initiated by a user gesture". Seems hard to fix.


0 rated :

Tying to force a video to play against the user's will is exactly the sort of behavior that makes users think of advertisers as assholes, and drives them to adblock. Please, don't be assholes.

This question has received the maximum number of answers.