2015-02-05 85 views
0

我目前在使用Kaltura HTML5 Player ver。 2.26。该documentation建议您可以将视频口味之间通过“doSwitch”通知,切换就像这样:Kaltura风味切换

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

我使用必须根据kdp.evaluate("{mediaProxy.kalturaMediaFlavorArray}") 6种不同口味的视频,但有各种不同的指数运行这没有任何明显的影响。我期望看到kdp触发了一个switchingChangeStarted事件,就像在使用源选择器插件UI时发生的情况一样,但这只是沉默。

github repo中搜索doSwitch,实际上我没有看到它在任何地方实现。这是一种遗失遗物吗?如果不是,我怎样才能让doSwitch通知起作用?

回答

0

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

你可以通过添加新的插件,会暴露出这样的通知扩展播放器的源选择如何做(sourceSelector.js :: 208),将切换类似来源:

_this.getPlayer().switchSrc(source) 

请注意,源列表可能包含在桌面上无法播放的来源,因此您不应将其用于切换。

+0

谢谢,罗马,这让我走下了正确的道路! – 2015-02-10 15:28:59

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