Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

138
Vistas
How can i do automictic Stop the Videos When Play Another Video in laravel site

I'm using YouTube iframe to embed videos on my site developed using php laravel framework. I want to ensure autometic stop others videos when i play one video. I am using following code but not workng it. Can anyone please help me!

<iframe id="youtube_player" class="yt_player_iframe" width="100%" height="350" 
 src="https://www.youtube.com/embed/{{$post->video_link}}" title="YouTube video player" 
 frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; 
 picture-in-picture" allowfullscreen></iframe>

 <script>
  $('.yt_player_iframe').each(function(){
  this.contentWindow.postMessage('{"event":"command","func":"stopVideo","args":""}', '*')
  });
</script>
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

To pause other videos and play the currently clicked one, You have to loop on each one and make sure it is not playing

I have created a sample function and you can workaround it:

// Function Argument takes the current player
function pauseOthersYoutubes( currentPlayer ) {
    // Make Sure there is a current video working, if not don't proceed
    if (!currentPlayer) return;
    //Loop to make sure all players are stopped unless the current player
    for (var i = ytplayerList.length; i-- ;){
        if( ytplayerList[i] && (ytplayerList[i] != currentPlayer) ){
            ytplayerList[i].pauseVideo();
        }
    }  
}
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda