Open forbesjo opened 5 years ago
A simple way to add it is to listen to the dispose
event on the player. Though, you definitely could migrate to the Plugin class.
Note also there's a bit of conversation around dispose in an active PR: https://github.com/videojs/videojs-contrib-eme/pull/47/files#diff-a4f485aa834ca5b3c24819fceb39c56fR257
There's a couple more things in the pipeline that tie in with disposal, which may be worth mentioning.
Using loadstart
to wipe/initialize sessions on source changes instead of the current method. We talked about it briefly on slack; it seems to be safe, and would fix an everlasting spinner bug after reloading the same source. That handler should be removed on player disposal.
Key rotation. It registers handlers for a couple events on player.tech_
(dunno if tech disposal is a thing that's used). It also uses a single handler function for the events fired by tech_.el_
, which would make removing them easier, though I imagine the video
element is destroyed during disposal and would thus be unnecessary?
It would probably make sense to do 1 in the same PR as cleaning up the handlers/data.
Previously a player could have leftover contrib-eme data because this plugin mutates the Player prototype. This was "fixed" in https://github.com/videojs/videojs-contrib-eme/pull/61/files#diff-a4f485aa834ca5b3c24819fceb39c56fR243 in that the
player.eme
is overwritten, cleaning upactiveSrc
andsessions
. However we should have a plugindispose
mechanism that cleans up handlers and data.