jwplayerjwplayer7

JWPlayer: Removing listeners on remove event


I have written a piece of code to unregister from JWPlayer events

jwPlayer().on('remove', function(e){ // taking the lisenters off jwplayer().off('error'); jwplayer().off('levelsChanged'); });

Problem is these "off" calls work, if they are called before remove is called on the player but after remove is called, the execution stops.

jwplayer().remove()

So my question is does "remove" removes the listeners and I dont have to do it manually or am I doing something wrong.


Solution

  • Yes using jwplayer().remove() resets the DOM to its original state and removes all listeners. You may want to take a look at the API documentation here: https://developer.jwplayer.com/jw-player/docs/developer-guide/api/javascript_api_reference/