首页 文章

Kaltura风味转换

提问于
浏览
0

我目前正在使用Kaltura HTML5 Player ver . 2.26 . documentation建议您可以通过"doSwitch"通知在视频风格之间切换,如下所示:

kdp.sendNotification("doSwitch", { flavorIndex: 3 });

根据 kdp.evaluate("{mediaProxy.kalturaMediaFlavorArray}") ,我使用的视频有6种不同的风格,但是使用各种不同的索引运行它并没有明显的效果 . 我希望看到 kdp 触发 switchingChangeStarted 事件,就像使用Source Selector插件UI时那样,但只是沉默 .

通过github repo搜索 doSwitch ,我实际上并没有看到它在任何地方实现 . 这种方法是丢失的遗物吗?如果没有,我如何让 doSwitch 通知工作?

2 回答

  • 0

    KDP是Kaltura flash播放器,它具有切换比特率的通知 . 加载无边框Flash播放器并单击源选择器按钮时,通知仍在内部使用 . 但它看起来不像V2播放器通知 .

    您可以通过添加一个新插件来扩展播放器,该插件将公开这样的通知,该通知将切换源类似于源选择器的操作方式(sourceSelector.js :: 208):

    _this.getPlayer().switchSrc( source )
    

    请注意,源列表可能包含无法在桌面上播放的源,您不应使用这些源进行切换 .

  • 0

    为了子孙后代,按照罗马的建议,这就是我最终做的事情 . 下面的插件几乎是最低限度,但这正是我想要的 .

    在嵌入中,我们需要声明自定义插件:

    kWidget.embed({
      ...
      "flashvars": {
        ...
        "sourceExposure": {
          "plugin": true,
          "iframeHTML5Js": "js/sourceExposure.js"
        }
      }
    }
    

    js/sourceExposure.js 中,我们需要声明一个提供对自定义事件(此处为"customDoSwitch")的响应的插件:

    (function(mw,$) {
      mw.kalturaPluginWrapper(function() {
        mw.PluginManager.add( 'sourceExposure', mw.KBaseComponent.extend({
    
          setup: function() {
            var _this = this;
    
            this.bind('customDoSwitch', function(evt, flavorIndex) {
              var sources = _this.getSources().slice(0)
              if (flavorIndex >= sources.length) {
                _this.log("Flavor Index too large.");
                return;
              }
              _this.getPlayer.switchSrc(_this.getSources()[flavorIndex]);
            })
          },
    
          getSources: function() {
            return this.getPlayer().getSources()
          }
        }));
      });
    })(window.mw, window.jQuery)
    

    当我们想要切换到不同的风格时,我们现在可以使用自定义事件并传递风味索引:

    kdp.sendNotification("customDoSwitch", 2) //switches to flavor index 2
    

相关问题