Reputation: 1300
According to facebook documentation - https://developers.facebook.com/docs/plugins/embedded-video-player/api , we subscribe to player events
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);
It seems that removeListener()
is not available on the token returned by subscribe()
. With a debugger, we see that there is a method release()
available on the token. Should that be used? Is it now official?
Am I doing something wrong?
Upvotes: 2
Views: 400
Reputation: 1300
there was and probably still is, unless FB changed something again, a release() method. it does what removeListen() should be doing.
Upvotes: 1