gpt4 book ai didi

javascript - 如何访问版本 5 中的 videojs.SeekBar 和 ControlBar?

转载 作者:行者123 更新时间:2023-11-30 00:20:21 30 4
gpt4 key购买 nike

我要移植this plugin到新的 videojs 版本 5。我更新了大部分插件以适应新的 videojs.extend() 要求并更新了公共(public)函数声明。

我坚持的部分是当您尝试将新组件加载到 videojs 中时:

 //Range Slider Time Bar
videojs.SeekBar.prototype.options_.children.RSTimeBar = {};
//Panel with the time of the range slider
videojs.ControlBar.prototype.options_.children.ControlTimePanel = {};

如果我理解正确(我有一些疑问),它正在扩展 videojs 的特定部分以包含插件组件。

问题是 videojs.SeekBarvideojs.ControlBar 是未定义的,我不知道在 v5 中访问它们的正确方法(或创建这些空的对象,如果它不再是你如何做的)。 videojs wiki文章“5.0 changes details”中也没有说明

The full code is available here. .故障线路为421和422


编辑

如果我将这些行替换为那些,我可以摆脱错误:

videojs.getComponent("SeekBar").prototype.options_.children.RSTimeBar = {}; //Range Slider Time Bar
videojs.getComponent("ControlBar").prototype.options_.children.ControlTimePanel = {}; //Panel with the time of the range slider

但是在插件构造函数中,我找不到组件:

  //components of the plugin
var controlBar = player.controlBar;
var seekBar = controlBar.progressControl.seekBar;
this.components.RSTimeBar = seekBar.RSTimeBar; //is undefined

当我探索 videoJs 对象时,在我的调试器中,我确实可以找到 player.controlBar.progressControl.seekBar 但它没有名为 RSTimebar 的子对象,除了options_.children。这是有道理的,因为它是我定义它的地方。但是不知道为什么4版能找到,5版就找不到。


编辑 2

我注意到 options_.children 数组中的 RSTimebar 是作为对象而不是一对索引/字符串插入的。所以我将台词改为:

    videojs.getComponent("SeekBar").prototype.options_.children.push("RSTimeBar"); //Range Slider Time Bar
videojs.getComponent("ControlBar").prototype.options_.children.push("ControlTimePanel"); //Panel with the time of the range slider

结果:插件正确加载,每个组件有一个警告:

VIDEOJS: WARN: The RSTimeBar component was added to the videojs object when it should be registered using videojs.registerComponent(name, component)

我现在只需要找出正确且最简单的方法来正确加载组件。

最佳答案

感谢 a commit,我终于成功更新了插件完成大部分工作的地方。

关于javascript - 如何访问版本 5 中的 videojs.SeekBar 和 ControlBar?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33389458/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com