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工作,或者我可以在特定名称空间或任何其他可能的解决方案中绑定此事件。
您可以将SiteCatalyst绑定到另一个定制的事件,然后在OnStateChange Triggers的功能中,您可以派遣该自定义事件:
'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
}