【问题标题】:Youtube IFrame Player API - Disable Youtube auto resume video where I left offYoutube IFrame Player API - 在我离开的地方禁用 Youtube 自动恢复视频
【发布时间】:2017-05-31 08:29:08
【问题描述】:

我正在使用 Youtube IFrame Player API 播放来自 Youtube 的视频。 我希望从头开始播放视频,但 Youtube 会自动从我上次中断的地方继续播放视频。

这是我的代码:

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();
                }
        }
})

我尝试使用startSecondsstart 参数,但它不起作用。

我该如何解决这个问题?

【问题讨论】:

    标签: javascript video iframe youtube


    【解决方案1】:

    尝试将start:0 更改为start:1

    这应该重置视​​频,但我不知道原因。

    我用带参数的直接url进行了测试。

    1. 以 start=0 example0 为例
    2. 开始 = 1 example1 的示例

    您会看到 start=1 可以正常工作。

    【讨论】:

    • 感谢您的回复。 start:1 表示视频从第一秒开始播放,而不是从头开始播放
    • 不确定this 是否对您有帮助。在小提琴中,我在播放器状态更改为播放后使用player.seekTo(0);
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-10
    • 2020-12-26
    • 2012-11-05
    • 1970-01-01
    • 2017-10-12
    • 2015-12-31
    相关资源
    最近更新 更多