Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Correctly dispose player components

Chocobozzz809fecf2b468
diff --git a/client/src/assets/player/shared/bezels/bezels-plugin.ts b/client/src/assets/player/shared/bezels/bezels-plugin.ts
index 6afb2c6a30..cf07dbd2c9 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 16883603e9..798a88db1a 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 0badcd68c9..45688978c1 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))
}
}