mirror of https://github.com/Chocobozzz/PeerTube
Fix changing video we are watching
parent
014ad87961
commit
ed9f9f5fb0
|
@ -69,6 +69,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
)
|
)
|
||||||
|
|
||||||
this.paramsSub = this.route.params.subscribe(routeParams => {
|
this.paramsSub = this.route.params.subscribe(routeParams => {
|
||||||
|
if (this.videoPlayerLoaded) {
|
||||||
|
this.player.pause()
|
||||||
|
}
|
||||||
|
|
||||||
let uuid = routeParams['uuid']
|
let uuid = routeParams['uuid']
|
||||||
this.videoService.getVideo(uuid).subscribe(
|
this.videoService.getVideo(uuid).subscribe(
|
||||||
video => this.onVideoFetched(video),
|
video => this.onVideoFetched(video),
|
||||||
|
@ -276,30 +280,35 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
return this.router.navigate([ '/videos/list' ])
|
return this.router.navigate([ '/videos/list' ])
|
||||||
}
|
}
|
||||||
|
|
||||||
this.playerElement = this.elementRef.nativeElement.querySelector('#video-element')
|
// Player was already loaded
|
||||||
|
if (this.videoPlayerLoaded !== true) {
|
||||||
|
this.playerElement = this.elementRef.nativeElement.querySelector('#video-element')
|
||||||
|
|
||||||
const videojsOptions = {
|
const videojsOptions = {
|
||||||
controls: true,
|
controls: true,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
plugins: {
|
plugins: {
|
||||||
peertube: {
|
peertube: {
|
||||||
videoFiles: this.video.files,
|
videoFiles: this.video.files,
|
||||||
playerElement: this.playerElement,
|
playerElement: this.playerElement,
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
peerTubeLink: false
|
peerTubeLink: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.videoPlayerLoaded = true
|
this.videoPlayerLoaded = true
|
||||||
|
|
||||||
const self = this
|
const self = this
|
||||||
videojs(this.playerElement, videojsOptions, function () {
|
videojs(this.playerElement, videojsOptions, function () {
|
||||||
self.player = this
|
self.player = this
|
||||||
this.on('customError', (event, data) => {
|
this.on('customError', (event, data) => {
|
||||||
self.handleError(data.err)
|
self.handleError(data.err)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
} else {
|
||||||
|
(this.player as any).setVideoFiles(this.video.files)
|
||||||
|
}
|
||||||
|
|
||||||
this.setVideoDescriptionHTML()
|
this.setVideoDescriptionHTML()
|
||||||
|
|
||||||
|
|
|
@ -283,6 +283,12 @@ const peertubePlugin = function (options: PeertubePluginOptions) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
player.setVideoFiles = function (files: VideoFile[]) {
|
||||||
|
player.videoFiles = files
|
||||||
|
|
||||||
|
player.updateVideoFile(undefined, () => player.play())
|
||||||
|
}
|
||||||
|
|
||||||
player.ready(function () {
|
player.ready(function () {
|
||||||
const controlBar = player.controlBar
|
const controlBar = player.controlBar
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue