From 809fecf2b4683bd0e9890233f8a707c59e25134b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 27 Jul 2023 14:49:49 +0200 Subject: Correctly dispose player components --- client/src/assets/player/shared/bezels/bezels-plugin.ts | 5 ++++- client/src/assets/player/shared/upnext/end-card.ts | 2 +- client/src/assets/player/shared/upnext/upnext-plugin.ts | 7 +++++-- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'client/src/assets') diff --git a/client/src/assets/player/shared/bezels/bezels-plugin.ts b/client/src/assets/player/shared/bezels/bezels-plugin.ts index 6afb2c6a3..cf07dbd2c 100644 --- a/client/src/assets/player/shared/bezels/bezels-plugin.ts +++ b/client/src/assets/player/shared/bezels/bezels-plugin.ts @@ -12,7 +12,10 @@ class BezelsPlugin extends Plugin { player.addClass('vjs-bezels') }) - player.addChild(new PauseBezel(player, options)) + const component = new PauseBezel(player, options) + player.addChild(component) + + this.on('dispose', () => player.removeChild(component)) } } diff --git a/client/src/assets/player/shared/upnext/end-card.ts b/client/src/assets/player/shared/upnext/end-card.ts index 16883603e..798a88db1 100644 --- a/client/src/assets/player/shared/upnext/end-card.ts +++ b/client/src/assets/player/shared/upnext/end-card.ts @@ -31,7 +31,7 @@ export interface EndCardOptions extends videojs.ComponentOptions, UpNextPluginOp } const Component = videojs.getComponent('Component') -class EndCard extends Component { +export class EndCard extends Component { options_: EndCardOptions dashOffsetTotal = 586 diff --git a/client/src/assets/player/shared/upnext/upnext-plugin.ts b/client/src/assets/player/shared/upnext/upnext-plugin.ts index 0badcd68c..45688978c 100644 --- a/client/src/assets/player/shared/upnext/upnext-plugin.ts +++ b/client/src/assets/player/shared/upnext/upnext-plugin.ts @@ -1,6 +1,6 @@ import videojs from 'video.js' import { UpNextPluginOptions } from '../../types' -import { EndCardOptions } from './end-card' +import { EndCard, EndCardOptions } from './end-card' const Plugin = videojs.getPlugin('plugin') @@ -24,7 +24,10 @@ class UpNextPlugin extends Plugin { player.addClass('vjs-upnext') }) - player.addChild('EndCard', settings) + const component = new EndCard(player, settings) + + player.addChild(component) + this.on('dispose', () => player.removeChild(component)) } } -- cgit v1.2.3