-
Notifications
You must be signed in to change notification settings - Fork 290
Description
Is there any recommended way to destroy the videojs-ima instance, when disposing the video-js player?
I'm using React (v17) and dispose the video-js player as soon my React Functional-Component unmounts:
useEffect(() => {
const player = playerRef.current;
return () => {
if (player && !player.isDisposed()) {
player.dispose();
playerRef.current = null;
}
};
}, [playerRef]);
This is the exact same way as recommended in the video-js documentation and it works as expected. When unmounting the component, the videoJs-player disposes.
When i unmount the component while an ad is playing, then i can still resume the ad via the notification that is shown from the browser (Chrome 114 on MacOS Ventura 13.4):

Please note, that i currently do not use the Media Session API to update the notification content, that is why the title shown in the notification is still the title of my video although an ad is playing. I tried it with both an sample adTag as well as our real-world adTag that is used in our productive application.
This only happens, when unmounting while an ad is playing. If i unmount while my video is playing, then the notification is no longer shown. I'm assuming, that the IMA adsManager-instance is not properly destroyed when unmounting the page. Unfortunately i cannot find the right way to destroy it. I already tried this:
player.ima.getAdsManager().destroy()
Any hint is highly appreciated. I can also give more informations on how i initialize the video-js player and the ima-sdk, if necessary.