How to remove a event handler from JWPlayer instance?
events, javascript, jwplayer
Solution
Looking at the code, it doesn't seem possible to remove an event listener: a callback is pushed onto an array when you call `onTime` (or any of the other methods to setup event handlers), so calling it a second time doesn't overwrite a previous listener but just adds a new listener to the array.
Perhaps an alternative could be to set a flag once your listener doesn't have to perform its task anymore:
onTimeHandler : function() {
if (! this.handleOnTimeEvents)
return;
...
}
Problem
I'm the using JWPlayer. After setup the player I need to add listeners to some events, to give an example I listen to `events.JWPLAYER_MEDIA_TIME` like so: ``` jwplayer('video-container').onTime(this.onTimeHandler); ``` After a while I need to remove this event listener, reading the documentation I couldn't find any solution.