diff options
author | Chocobozzz <me@florianbigard.com> | 2019-02-07 15:56:17 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-02-11 09:13:02 +0100 |
commit | 597a9266d426aa04c2f229168e4285a76bea2c12 (patch) | |
tree | 2a6fe84ae7651a8a943939192697e2fdbe9f0b43 /client/src/app | |
parent | 4c280004ce62bf11ddb091854c28f1e1d54a54d6 (diff) | |
download | PeerTube-597a9266d426aa04c2f229168e4285a76bea2c12.tar.gz PeerTube-597a9266d426aa04c2f229168e4285a76bea2c12.tar.zst PeerTube-597a9266d426aa04c2f229168e4285a76bea2c12.zip |
Add player mode in watch/embed urls
Diffstat (limited to 'client/src/app')
-rw-r--r-- | client/src/app/videos/+video-watch/video-watch.component.ts | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index e1766255b..9f3a43a08 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -27,8 +27,7 @@ import { | |||
27 | P2PMediaLoaderOptions, | 27 | P2PMediaLoaderOptions, |
28 | PeertubePlayerManager, | 28 | PeertubePlayerManager, |
29 | PeertubePlayerManagerOptions, | 29 | PeertubePlayerManagerOptions, |
30 | PlayerMode, | 30 | PlayerMode |
31 | WebtorrentOptions | ||
32 | } from '../../../assets/player/peertube-player-manager' | 31 | } from '../../../assets/player/peertube-player-manager' |
33 | 32 | ||
34 | @Component({ | 33 | @Component({ |
@@ -117,8 +116,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
117 | .subscribe(([ video, captionsResult ]) => { | 116 | .subscribe(([ video, captionsResult ]) => { |
118 | const startTime = this.route.snapshot.queryParams.start | 117 | const startTime = this.route.snapshot.queryParams.start |
119 | const subtitle = this.route.snapshot.queryParams.subtitle | 118 | const subtitle = this.route.snapshot.queryParams.subtitle |
119 | const playerMode = this.route.snapshot.queryParams.mode | ||
120 | 120 | ||
121 | this.onVideoFetched(video, captionsResult.data, { startTime, subtitle }) | 121 | this.onVideoFetched(video, captionsResult.data, { startTime, subtitle, playerMode }) |
122 | .catch(err => this.handleError(err)) | 122 | .catch(err => this.handleError(err)) |
123 | }) | 123 | }) |
124 | }) | 124 | }) |
@@ -365,7 +365,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
365 | ) | 365 | ) |
366 | } | 366 | } |
367 | 367 | ||
368 | private async onVideoFetched (video: VideoDetails, videoCaptions: VideoCaption[], urlOptions: { startTime: number, subtitle: string }) { | 368 | private async onVideoFetched ( |
369 | video: VideoDetails, | ||
370 | videoCaptions: VideoCaption[], | ||
371 | urlOptions: { startTime?: number, subtitle?: string, playerMode?: string } | ||
372 | ) { | ||
369 | this.video = video | 373 | this.video = video |
370 | 374 | ||
371 | // Re init attributes | 375 | // Re init attributes |
@@ -440,10 +444,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
440 | } | 444 | } |
441 | } | 445 | } |
442 | 446 | ||
443 | let mode: PlayerMode | 447 | const mode: PlayerMode = urlOptions.playerMode === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent' |
444 | const hlsPlaylist = this.video.getHlsPlaylist() | 448 | |
445 | if (hlsPlaylist) { | 449 | if (mode === 'p2p-media-loader') { |
446 | mode = 'p2p-media-loader' | 450 | const hlsPlaylist = this.video.getHlsPlaylist() |
447 | 451 | ||
448 | const p2pMediaLoader = { | 452 | const p2pMediaLoader = { |
449 | playlistUrl: hlsPlaylist.playlistUrl, | 453 | playlistUrl: hlsPlaylist.playlistUrl, |
@@ -454,8 +458,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
454 | } as P2PMediaLoaderOptions | 458 | } as P2PMediaLoaderOptions |
455 | 459 | ||
456 | Object.assign(options, { p2pMediaLoader }) | 460 | Object.assign(options, { p2pMediaLoader }) |
457 | } else { | ||
458 | mode = 'webtorrent' | ||
459 | } | 461 | } |
460 | 462 | ||
461 | this.zone.runOutsideAngular(async () => { | 463 | this.zone.runOutsideAngular(async () => { |