Youtube IFrame Player API - Disable Youtube auto r

2019-08-19 00:58发布

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条回答
时光不老,我们不散
2楼-- · 2019-08-19 01:29

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.

查看更多
登录 后发表回答