You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

YTPlayer中endAt参数失效,视频无法按时终止求助

YTPlayer endAt参数失效的解决办法
  • 检查插件版本
    旧版YTPlayer存在endAt参数的兼容性bug,先确认你使用的是最新版本的YTPlayer插件,更新后再测试endAt是否正常生效。

  • 排查loop参数冲突
    当loop:true时,部分版本的YTPlayer会优先执行循环逻辑,忽略endAt的停止设置。可以先将loop改为false测试:

<div class="thevideo">
  <div
    class="video-player"
    data-property="{videoURL:'https://www.youtube.com/watch?v=VwWY-Zh-KLM', containment:'.home-section', startAt:30, endAt:60, mute:true, autoPlay:true, loop:false, opacity:1, showControls:false, showYTLogo:false}"
  ></div>
</div>

如果endAt恢复正常,说明是loop参数导致的冲突。

  • 手动监听时间实现停止/循环
    如果需要保留循环功能,直接通过事件监听手动控制视频播放进度,绕过插件的参数限制:
// 初始化YTPlayer并添加进度监听
$(".video-player").YTPlayer({
  videoURL: 'https://www.youtube.com/watch?v=VwWY-Zh-KLM',
  containment: '.home-section',
  startAt: 30,
  mute: true,
  autoPlay: true,
  opacity: 1,
  showControls: false,
  showYTLogo: false,
  onProgress: function(event) {
    const currentTime = event.target.getCurrentTime();
    // 当播放到60秒时,跳回30秒继续循环
    if (currentTime >= 60) {
      event.target.seekTo(30);
    }
  }
});

这种方式直接通过YouTube原生API控制播放进度,稳定性更高。

内容的提问来源于stack exchange,提问作者Chris Clark

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.16 15:27:10