根据facebook文档 - https://developers.facebook.com/docs/plugins/embedded-video-player/api,我们订阅了玩家活动
var handleDesktopEvents = function (msg) {
if (msg.type === 'video') {
var player = msg.instance;
var playHandler = player.subscribe('startedPlaying', function() {
// Video started playing ...
player.unmute();
console.log('detected video playing');
ga_virtual_pagehit(msg.id);
console.log('sent event to GA');
playHandler.removeListener('startedPlaying');
// playHandler.release();
});
console.log('detected video ready');
player.play();
FB.Event.unsubscribe('xfbml.ready', handleDesktopEvents, handleDesktopEx);
}
};
var handleDesktopEx = function () {
// Handle pause() and exceptions
console.log('detected pause');
};
FB.Event.subscribe('xfbml.ready', handleDesktopEvents, handleDesktopEx);
removeListener()
返回的令牌似乎无法subscribe()
。使用调试器,我们可以看到令牌上有一个方法release()
。应该用吗?现在是官方的吗?
我做错了吗?
答案 0 :(得分:1)
除非FB再次改变了一些东西,否则可能仍然存在,即释放()方法。它执行removeListen()应该做的事情。