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

177
Vistas
Vue youtube embed pause other video when playing another

I'm using this plugin https://www.npmjs.com/package/vue-youtube-embed to create two videos on a page in a vue app I am building. What I am trying to do is when playing one video pause the other. I was able to achieve this if the videos are in the same component using refs. My problem is each of the videos is nested inside a component and then placed on a parent page. Is there a way to have the same functionality but called from the parent? or a sibling communication?

I think this is more of a question of can you access a sibling components $ref? or is there a better approach possibly using store?

Same Component: (works as expected)

<div>
  <div class="l-text-image-band-media">
    <youtube 
      video-id="0mS0uT_wrhg" 
      @playing="stopOtherVideo('player2')" 
      ref="player1"
    ></youtube>
  </div>
  <div class="l-text-image-band-media">
    <youtube 
      video-id="0md0uT_wg7g" 
      @playing="stopOtherVideo('player1')" 
      ref="player2"
    ></youtube>
  </div>
</div>
methods: {
  stopOtherVideos(target) {
    this.$refs[target].player.stopVideo();
  },
}

Parent: (each component with videos nested in each)

<template>
  <div>
    <main class="main-content" id="main-content" tabindex="-1">
      <ResponsibilityByTheNumbers 
        is-video-component="true" 
        :text="handsOnText" 
      />   
      <ResponsibilityWhiteBandLeftText 
        is-video-component="true" 
        :showPrism="showPrism"
        :text="stemVideoBandText" 
      />
    </main>
  </div>
</template>

Video Component (only showing one) does not work

<youtube 
      video-id="0md0uT_wg7g" 
      @playing="stopOtherVideo('player1')" 
      ref="player2"
    ></youtube>

methods: {
  stopOtherVideos(target) {
    this.$refs[target].player.stopVideo();
  },
}
about 4 years ago · Juan Pablo Isaza
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