anteriovieira / vue-youtube

A simple component for a powerful API. vue-youtube provides a simple layer for you to use your imagination while over the YouTube IFrame Player API.
MIT License
341 stars 56 forks source link

Player variable: startSeconds not working #27

Open kidabu9x opened 5 years ago

kidabu9x commented 5 years ago

Hi, I'm trying to make the video start with a specific second. I read the document https://developers.google.com/youtube/iframe_api_Vference#loadVideoByUrl and try to add "startSeconds" to the "player-vars" prop but it doesn't seem to work

TitanFighter commented 5 years ago

You can try to use the code below:

computed: {
    ....

    player () {
      return this.$refs.youtube.player
    },

    ....
},

methods: {
    ... 

    youtubeSeekTo () {
      this.player.seekTo(10)
    },

    ...
}

EDIT It seems you need start parameter: https://developers.google.com/youtube/player_parameters#start

jeff-hykin commented 4 years ago

.seekTo() isn't quite the same because instead of showing the thumbnail, the youtube player looks like it's stuck in an infinite loading loop until the video is played.

I have the same issue but with the start parameter too.

If I set autoplay=1, and start then it does start at the start time, but its stays paused and shows the loading spinner indefinitely. So that doesn't make much sense but its there.

morsecodemedia commented 3 years ago

Has anyone gotten this to successfully work?

jeff-hykin commented 3 years ago

Yes, but the workaround was terrible.

Took me a month to make a huge bulky wrapper around the system. The initial hack should be play, pause, then seek. But that's actually way way harder than it sounds because if you do .play() , .pause() then it's too fast and they cancel out and just stay paused. So you have to add a timed delay between the play and the pause, and if your user tries to click play/pause during your timed delay, everything gets wrecked. My workaround went all over the place including an invisible element infront of the player to prevent/catch clicking, and a system to shift focus away from the iframe to catch keystrokes.

To be fair this isn't a Vue YouTube problem. It's a embedded YouTube problem.