Embedded YouTube videos autoplay randomly when scrolling up


#1

If a YouTube video in a post is paused or finished playing and you scroll up or down the page enough to load new posts, the aforementioned video will start playing automatically. I’ve successfully recreated this issue on Windows 7 in Chrome version 56.0.2924.87 in this thread: Post your favorite video game glitches - General Game Discussion - Let’s Play Zone

  1. Load the post in the page above
  2. Play one or all of the videos in the post
  3. Pause them at any point
  4. Scroll up the page until the browser loads in new comments
  5. The videos will autoplay without any interaction

Here’s a thread about it on my forum if it’s of any help: Embedded Youtube Video Replaying - Site Feedback - Let’s Play Zone


(Chris Saenz) #2

Possibly related to this bugfix:


(Sam Saffron) #3

From what I can see on the linked topic it appears the issue is still happening @eviltrout


(Robin Ward) #5

I have spent a lot of time this afternoon on this issue and I feel like this issue might not be fixable unless someone else has a brilliant idea.

The problem is in the virtual DOM with prepending (scrolling up). In this case, you are adding a bunch of elements (posts) to the beginning of an array. When the virtual DOM does its diff, it notices the element with the youtube <iframe> is not in the same place, so it removes and re-adds it later. This causes the youtube player to refresh the iframe, which causes it to play again.

It seems impossible to move an <iframe> in the DOM without reloading it.

Note that this bug doesn’t happen when scrolling down because appending posts doesn’t change the order. It also doesn’t matter if the user hasn’t started the video already, because lazyYT hasn’t inserted the iframe yet.


Paused videos resume when scrolling through pages
(Jeff Atwood) #6

So this does not happen in the scrolling down scenario?


(Robin Ward) #7

No it doesn’t happen when scrolling down.


(Jeff Atwood) #8

I have edited the topic to make this more clear.


(Daniela) #9

A similar bug happens if you don’t stop the video. When you scrolling up the page, the video stops and after few seconds restart from the beginning.