amphtml icon indicating copy to clipboard operation
amphtml copied to clipboard

amp-youtube stops videos after initial video load in amp-lightbox

Open gavingrv opened this issue 5 years ago • 1 comments

What's the issue?

When using the amp-youtube element inside of amp-lightbox, after the initial video has played - any videos to play after will just freeze and continuously stop working.

How do we reproduce the issue?

I have created a JSFiddle which reproduces this issue: https://jsfiddle.net/f4rjn2wg/2/

  1. Click any button to open the lightbox with the video in it.
  2. Close the lightbox
  3. Open another video (or the same one) by clicking one of the buttons
  4. The video will then continuously freeze rather than play as intended

I have created another example below it outside of the lightbox to demonstrate what sort of result I would expect.

What browsers are affected?

All major browsers I have tested

Which AMP version is affected?

Latest version

gavingrv avatar Jan 25 '21 14:01 gavingrv

This reproduces more simply without amp-bind:

    <button on="tap: lightbox">Open</button>
    <amp-lightbox id="lightbox" layout="nodisplay">
      <div>
        <amp-youtube
          width="480"
          height="270"
          layout="responsive"
          data-videoid="5IZrYeUX3MI"
        ></amp-youtube>
        <button on="tap: lightbox.close">close</button>
      </div>
    </amp-lightbox>
  1. When closing the lightbox, the <amp-youtube> element is unlaid out.
  2. When opening the lightbox a second time, the <amp-youtube> element is laid out again.

The VideoManager then incorrectly stores two entries. When playing for a second time it will pauseOtherVideos(), incorrectly pausing itself—so the video never plays.

Fix on #32220

alanorozco avatar Jan 26 '21 20:01 alanorozco