Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!