amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp-video autoplay doesn't work in amp4ads

Open heather162 opened this issue 8 years ago • 21 comments

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

heather162 avatar Aug 29 '18 21:08 heather162

/to @alanorozco maybe?

cathyxz avatar Aug 30 '18 18:08 cathyxz

@alanorozco setting to P1.

aghassemi avatar Sep 04 '18 22:09 aghassemi

This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?

ampprojectbot avatar Sep 25 '18 08:09 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?

ampprojectbot avatar Oct 16 '18 08:10 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?

ampprojectbot avatar Nov 08 '18 02:11 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?

ampprojectbot avatar Nov 28 '18 01:11 ampprojectbot

This is a high priority issue but it hasn't been updated in awhile. @alanorozco Do you have any updates?

ampprojectbot avatar Jan 09 '19 09:01 ampprojectbot

CC @jasti

cramforce avatar Mar 29 '19 12:03 cramforce

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!

jasti avatar Mar 29 '19 21:03 jasti

Looking at it today, will update later.

alanorozco avatar Apr 04 '19 17:04 alanorozco

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?

alanorozco avatar Apr 04 '19 19:04 alanorozco

Pinging this thread to get an update from OP @heather162 heather162

nainar avatar Jun 03 '19 09:06 nainar

This happens when trying to preview an AMPHTML ad in the browser, loading the AMP4ADS document doesn't autoplay the video.

heather162 avatar Jun 03 '19 19:06 heather162

@heather162 any chance you have a test page handy?

jasti avatar Jun 03 '19 22:06 jasti

The example document in the bug description still doesn't autoplay when loaded in the browser.

heather162 avatar Jun 03 '19 22:06 heather162

Ah, of course. @alanorozco I can repro it too.

jasti avatar Jun 03 '19 22:06 jasti

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

wassgha avatar Jul 26 '19 16:07 wassgha

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.

lannka avatar Jul 26 '19 16:07 lannka

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.

lannka avatar Jul 26 '19 16:07 lannka

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.

wassgha avatar Jul 26 '19 20:07 wassgha