- // Player was already loaded
- if (this.videoPlayerLoaded !== true) {
- this.playerElement = this.elementRef.nativeElement.querySelector('#video-element')
-
- // If autoplay is true, we don't really need a poster
- if (this.isAutoplay() === false) {
- this.playerElement.poster = this.video.previewUrl
- }
-
- const videojsOptions = {
- controls: true,
- autoplay: this.isAutoplay(),
- playbackRates: [ 0.5, 1, 1.5, 2 ],
- plugins: {
- peertube: {
- videoFiles: this.video.files,
- playerElement: this.playerElement,
- videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid),
- videoDuration: this.video.duration
- },
- hotkeys: {
- enableVolumeScroll: false
- }
- },
- controlBar: {
- children: [
- 'playToggle',
- 'currentTimeDisplay',
- 'timeDivider',
- 'durationDisplay',
- 'liveDisplay',
-
- 'flexibleWidthSpacer',
- 'progressControl',
-
- 'webTorrentButton',
-
- 'playbackRateMenuButton',
-
- 'muteToggle',
- 'volumeControl',
-
- 'resolutionMenuButton',
+ // Player was already loaded, remove old videojs
+ if (this.videojsInstance) {
+ this.videojsInstance.dispose()
+ this.videojsInstance = undefined
+ }