Youtube IFrame Player API - Disable Youtube auto r

2019-08-19 01:13发布

问题:

I'm using the Youtube IFrame Player API to play a video from Youtube. I want the video to be played from the beginning but Youtube automatically resume the video from where I last left off.

Here is my code:

new YT.Player('yt-player', {
        height: '439',
        width: '100%',
        videoId: 'my-video-id',
        startSeconds: 0,
        playerVars: {
                controls: 0,
                color: 'white',
                disablekb: 1,
                enablejsapi: 0,
                modestbranding: 1,
                rel: 0,
                showinfo: 1,
                iv_load_policy: 3,
                start: 0
        },
        events: {
                onReady: function() {
                         this.playVideo();
                }
        }
})

I tried using startSeconds and start parameters but it does not work.

How can I fix this problem?

回答1:

Try to change the start:0 to start:1.

This should reset the video but I don't know the reason.

I tested with direct url with parameters.

  1. Example with start=0 example0
  2. Example with start=1 example1

You will see that start=1 will works correctly.