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.
OK our debugging shows that for some reason the Youtube embedded player did fix the autoplay thing, so I am fixing the title here.
The bug we have is that we have “protection” in place when you click play that tells the “post cloaker”, hi … don’t cloak me. But this protection is somehow binned when you scroll up.
This means that if you play a song on youtube and scroll up it will just stop playing when we load the next chunk.
Sorry to resurrect this, but I’ve noticed this starts happening now even when scrolling down. Not sure if something changed this bug recently to the worse, or if it’s a different bug altogether. Confirmed with several people in our instance. This makes video sharing threads quite unbearable, when the earlier videos start suddenly playing.
Doy fe de esto, sucede al desplazarse hacia arriba o hacia abajo y reproduce aleatoriamente todos los videos reproducidos anteriormente (imagino que tiene algo que ver con cómo Discourse procesa el contenido anterior al cargar contenido nuevo en un tema, pero honestamente no lo sé).
Tengo sentimientos encontrados al respecto, no creo que la gente deba esperar que un video de más de 600 publicaciones anteriores continúe reproduciéndose mientras te desplazas sin fin en un megatema. El video no es visible, y no lo ha sido durante un tiempo si te estás desplazando hacia abajo.
Por ejemplo, si quieres reproducir audio durante mucho tiempo mientras navegas, en cualquier sitio que visites, ¿lo abres en una nueva pestaña?
En mi opinión, no debería. Si el video se pausa o termina, no debería reproducirse solo porque te desplazaste hacia abajo. (Que es el comportamiento descrito, aunque el título sea engañoso)
De hecho, existe una alternativa para las personas que quieren que “la gente siga reproduciendo” mientras navegan, si encuentran que el enfoque de pestañas es demasiado.
Esto todavía sucede en la versión estable 3.0. Lo gracioso es que un video se actualiza al desplazarse hacia ARRIBA, al desplazarse hacia ABAJO todavía está pausado, otro video aleatorio hace lo contrario. Permanece pausado al desplazarse hacia ARRIBA y se reproduce al desplazarse hacia ABAJO.
Nuestro plan es reconstruir nuestra vista de temas durante el próximo año o dos, lo que esperamos que mejore la situación. No hay una solución fácil aquí, lo intentamos.