Fix changing video we are watching

pull/159/head
Chocobozzz 2017-12-11 11:20:54 +01:00
parent 014ad87961
commit ed9f9f5fb0
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
2 changed files with 33 additions and 18 deletions

View File

@ -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,6 +280,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
return this.router.navigate([ '/videos/list' ]) return this.router.navigate([ '/videos/list' ])
} }
// Player was already loaded
if (this.videoPlayerLoaded !== true) {
this.playerElement = this.elementRef.nativeElement.querySelector('#video-element') this.playerElement = this.elementRef.nativeElement.querySelector('#video-element')
const videojsOptions = { const videojsOptions = {
@ -300,6 +306,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
self.handleError(data.err) self.handleError(data.err)
}) })
}) })
} else {
(this.player as any).setVideoFiles(this.video.files)
}
this.setVideoDescriptionHTML() this.setVideoDescriptionHTML()

View File

@ -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