为了后代的缘故,我按照罗曼的建议做了最后的工作。下面的插件几乎是最低限度的,但这正是我想要的。
在嵌入,我们需要声明的自定义插件:
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
谢谢,罗马,这让我走下了正确的道路! – 2015-02-10 15:28:59