videojs / videojs-contrib-ads

A Tool for Building Video.js Ad Plugins
http://videojs.github.io/videojs-contrib-ads/
Other
379 stars 257 forks source link

Is there any way to clear or deregister the videojs-contrib-ads plugin for removing event binding and such as? #559

Open JonasWater opened 1 year ago

JonasWater commented 1 year ago

The project is great!

And the scenario I encountered: I want to remove the plugin from the current environment, for example: deregister the plugin and remove all event bindings. I found that after deregister the videojs-contrib-ads plugin , The player's play event is still affected by the plugin.

So is there any way to clear the videojs-contrib-ads plugin?

Thx~

alex-barstow commented 1 year ago

Calling deregisterPlugin() will not clean up event handlers added by the plugin. To do that you will need to dispose the player by calling player.dispose(). However, even doing this will not clean up the play middleware that this plugin creates, as that is added to the global videojs instance and not the player. It is possible that calling dispose() will accomplish what you need in your specific case, so I'd recommend trying that. To better assist you, it would also be helpful for us to understand why you are trying to deregister the plugin to begin with.