amp-video autoplay doesn't work in amp4ads
What's the issue?
In an amp4ads document amp-video with the autoplay attribute does not autoplay when loading the page in a desktop browser (not tested on mobile). If you switch tabs and come back to the amp4ads document then the video autoplays. It works fine for regular AMP documents.
How do we reproduce the issue?
Example amp4ads document which doesn't autoplay.
<html ⚡4ads>
<head>
<meta charset="utf-8">
<script async src="https://cdn.ampproject.org/amp4ads-v0.js"></script>
<script async custom-element="amp-video" src="https://cdn.ampproject.org/v0/amp-video-0.1.js"></script>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<style amp4ads-boilerplate>body{visibility:hidden}</style>
</head>
<body>
<amp-video width="720"
height="405"
src="https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4"
poster="https://peach.blender/org/wp-content/uploads/bbb-splash.png"
layout="responsive"
controls
autoplay>
<div fallback>
<p>Your browser doesn't support HTML5 video.</p>
</div>
</amp-video>
</body>
</html>
The same amp-video tag inserted in a regular AMP document does autoplay.
What browsers are affected?
Chrome 68.0.3440.106, Safari 11.1.2 and Firefox 61.0.2 didn't work
Which AMP version is affected?
Tested with version 1535038987988
/to @alanorozco maybe?
@alanorozco setting to P1.
This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?
This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?
This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?
This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?
This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?
CC @jasti
Bumping up priority. @alanorozco, could you please confirm if you are able to take a look at this issue in the relatively near term? Thanks!
Looking at it today, will update later.
This does not repro on friendly iframes. @heather162 it would be nice to have more info:
- does this happen on a non-AMP page embedding an AMP ad?
- does this happen on an AMP page embedding an AMP ad in the origin?
Pinging this thread to get an update from OP @heather162 heather162
This happens when trying to preview an AMPHTML ad in the browser, loading the AMP4ADS document doesn't autoplay the video.
@heather162 any chance you have a test page handy?
The example document in the bug description still doesn't autoplay when loaded in the browser.
Ah, of course. @alanorozco I can repro it too.
more info: behavior is consistent across all video elements supporting autoplay, not only amp-video, investigating now.
update2: looked into whether this is part of the amp4ads format and while autoplay was prohibited at some point, the format was updated to support it through #14641
update3: works fine inside the a4a envelope, breaks inside the a4a-3p envelope
thanks @wassgha for looking at this. this is very important as we have some DSP partners wanting this autoplay feature. let me know if anything I can help
to test under inabox, you should use the /inabox/ envelop.
I don't know why it fails in inabox, but one possible solution is to refactor the autoplay logic to use IntersectionObserver, that's how amp-analytics visibility tracking working in inabox.
As per @lannka , the behavior is expected for standalone pages using amp4ads (because they rely on a different mechanism to measure whether the video is visible or not) but it should work under inabox (and it currently does) so @heather162 if you can provide a case where the autoplay doesn't work while the ad is embedded inside a page (whether amp or non-amp) please let us know and reopen this bug.