player = new YT.Player(A, {
videoId: z.videoId,
height: z.height,
width: z.width,
playerVars: {
autoplay: (z.autoplay ? 1 : 0),
autohide: (z.autoHide ? 1 : 0),
controls: (z.showControls ? 1 : 0),
loop: (z.loop ? 1 : 0),
rel: (z.showRelated ? 1 : 0),
fs: (z.allowFullScreen ? 1 : 0),
theme: z.theme,
wmode: "transparent"
},
events: {
'onReady': function (event) {alert("onReady")},
'onStateChange': function (event) {alert("onChange")}
}
});
此代码适用于开发环境。在我们的测试服务器上,我们使用Adobe Sitecatalyst进行跟踪,它也绑定了onStateChange。
有人可以建议,如何使多个onStateChange工作,或者我可以在特定的命名空间或任何其他可能的解决方案中绑定此事件。
答案 0 :(得分:0)
您可以将Sitecatalyst绑定到另一个自定义命名的事件,然后在onStateChange触发的函数中,您可以调度该自定义事件:
'onStateChange': function (event) {
alert("onChange");
var event = new CustomEvent('siteCatalystOnStateChange', { 'data': event.data }); // here's the event SiteCatalyst will listen for. It's a custom event so you can pass additional parameters; the listener function is passed the object
elem.dispatchEvent(event); // elem is the element that SiteCatalyst is listening on
}