【问题标题】:VideoJS - videojs.getComponent(...) is undefinedVideoJS - videojs.getComponent(...) 未定义
【发布时间】:2018-04-03 10:55:23
【问题描述】:

我正在使用允许我在 video-js 中显示广告的插件。

https://github.com/dirkjanm/videojs-preroll/blob/master/lib/videojs.ads.js

这在第 5 版之前运行良好,但现在我想迁移到第 6 版,这个插件不再有效,日志向我抛出以下错误:

TypeError: videojs.getComponent(...) is undefined               videojs.ads.js:386

似乎一切都在插件的这一部分(第 386 行):

    (function() {
      var
        videoEvents = videojs.getComponent('Html5').Events,
        i,
        returnTrue = function() { return true; },
        triggerEvent = function(type, event) {
          // pretend we called stopImmediatePropagation because we want the native
          // element events to continue propagating
          event.isImmediatePropagationStopped = returnTrue;
          event.cancelBubble = true;
          event.isPropagationStopped = returnTrue;
          player.trigger({
            type: type + event.type,
            state: player.ads.state,
            originalEvent: event
          });
},

该插件前段时间没有更新,所以我也给了一些关于如何注册插件的警告,但是我可以解决它,我对javascript不太了解,所以我不知道如何解决那个。

【问题讨论】:

    标签: javascript jquery plugins compatibility video.js


    【解决方案1】:

    好的同志们,我一直在阅读videojs 6的手册,显然要解决这个问题只需要换一行:

    videojs.getComponent -to- videojs.getTech
    

    我把它留在这里,以防有人遇到同样的问题。 当然,我不是 Javascript 专家,所以老实说,我不知道该如何解释。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-02
      • 1970-01-01
      • 1970-01-01
      • 2019-07-01
      • 1970-01-01
      • 2021-02-05
      相关资源
      最近更新 更多