Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how access player object in youtube component? #20

Closed
gn-spawn opened this issue Apr 19, 2017 · 3 comments
Closed

how access player object in youtube component? #20

gn-spawn opened this issue Apr 19, 2017 · 3 comments

Comments

@gn-spawn
Copy link

i want to do getCurrentTime() method.
how can use it?

@kaorun343
Copy link
Owner

@gn-spawn

Hi.

Every events pass a player object.
Please check my vue-play example.

@kaorun343
Copy link
Owner

kaorun343 commented Apr 19, 2017

Ah, please check here.

https://github.com/kaorun343/vue-youtube-embed/blame/master/README.md#L125

<template>
<div>
  <youtube @ready="ready"></youtube>
</div>
</template>
<script>
export default {
  methods: {
    ready (player) {
      this.youtubePlayer = player
      const time = this.youtubePlayer.getCurrentTime()
    }
  }
}
</script>

@kaorun343
Copy link
Owner

kaorun343 commented Apr 20, 2017

Or, how about vm.$refs.yourPlayer.player?

https://github.com/kaorun343/vue-youtube-embed/blob/master/src/player.js#L43

<template>
<div>
  <youtube ref="yourPlayer"></youtube>
</div>
</template>
<script>
export default {
  mounted () {
    const { player } = this.$refs.yourPlayer
    this.id = setInterval(() => {
      this.currentTime = player.getCurrentTime()
    }, 100)
  },
  beforeDestroy () {
     clearInterval(this.id)
  }
}
</script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants