- observable.subscribe(
- res => {
- if (res === false) {
-
- return this.router.navigate([ '/videos/list' ])
- }
-
- this.playerElement = this.elementRef.nativeElement.querySelector('#video-container')
-
- const videojsOptions = {
- controls: true,
- autoplay: true,
- plugins: {
- peertube: {
- videoFiles: this.video.files,
- playerElement: this.playerElement,
- autoplay: true,
- peerTubeLink: false
- }
- }
- }
+ // Flush old player if needed
+ this.flushPlayer()
+
+ // Build video element, because videojs remove it on dispose
+ const playerElementWrapper = this.elementRef.nativeElement.querySelector('#video-element-wrapper')
+ this.playerElement = document.createElement('video')
+ this.playerElement.className = 'video-js vjs-peertube-skin'
+ playerElementWrapper.appendChild(this.playerElement)
+
+ const videojsOptions = getVideojsOptions({
+ autoplay: this.isAutoplay(),
+ inactivityTimeout: 2500,
+ videoFiles: this.video.files,
+ playerElement: this.playerElement,
+ videoViewUrl: this.videoService.getVideoViewUrl(this.video.uuid),
+ videoDuration: this.video.duration,
+ enableHotkeys: true,
+ peertubeLink: false,
+ poster: this.video.previewUrl,
+ startTime
+ })