From: Chocobozzz Date: Thu, 7 Feb 2019 14:56:17 +0000 (+0100) Subject: Add player mode in watch/embed urls X-Git-Tag: v1.3.0-rc.1~205^2~2^2~9 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=597a9266d426aa04c2f229168e4285a76bea2c12;p=oweals%2Fpeertube.git Add player mode in watch/embed urls --- 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 { P2PMediaLoaderOptions, PeertubePlayerManager, PeertubePlayerManagerOptions, - PlayerMode, - WebtorrentOptions + PlayerMode } from '../../../assets/player/peertube-player-manager' @Component({ @@ -117,8 +116,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy { .subscribe(([ video, captionsResult ]) => { const startTime = this.route.snapshot.queryParams.start const subtitle = this.route.snapshot.queryParams.subtitle + const playerMode = this.route.snapshot.queryParams.mode - this.onVideoFetched(video, captionsResult.data, { startTime, subtitle }) + this.onVideoFetched(video, captionsResult.data, { startTime, subtitle, playerMode }) .catch(err => this.handleError(err)) }) }) @@ -365,7 +365,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { ) } - private async onVideoFetched (video: VideoDetails, videoCaptions: VideoCaption[], urlOptions: { startTime: number, subtitle: string }) { + private async onVideoFetched ( + video: VideoDetails, + videoCaptions: VideoCaption[], + urlOptions: { startTime?: number, subtitle?: string, playerMode?: string } + ) { this.video = video // Re init attributes @@ -440,10 +444,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } } - let mode: PlayerMode - const hlsPlaylist = this.video.getHlsPlaylist() - if (hlsPlaylist) { - mode = 'p2p-media-loader' + const mode: PlayerMode = urlOptions.playerMode === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent' + + if (mode === 'p2p-media-loader') { + const hlsPlaylist = this.video.getHlsPlaylist() const p2pMediaLoader = { playlistUrl: hlsPlaylist.playlistUrl, @@ -454,8 +458,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } as P2PMediaLoaderOptions Object.assign(options, { p2pMediaLoader }) - } else { - mode = 'webtorrent' } this.zone.runOutsideAngular(async () => { diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts index c5c46d0c5..32bf42e12 100644 --- a/client/src/standalone/videos/embed.ts +++ b/client/src/standalone/videos/embed.ts @@ -263,7 +263,7 @@ class PeerTubeEmbed { this.subtitle = this.getParamString(params, 'subtitle') this.startTime = this.getParamString(params, 'start') - this.mode = this.getParamToggle(params, 'p2p-media-loader') ? 'p2p-media-loader' : 'webtorrent' + this.mode = this.getParamString(params, 'mode') === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent' } catch (err) { console.error('Cannot get params from URL.', err) } diff --git a/server/lib/job-queue/handlers/video-file.ts b/server/lib/job-queue/handlers/video-file.ts index 7119ce0ca..04983155c 100644 --- a/server/lib/job-queue/handlers/video-file.ts +++ b/server/lib/job-queue/handlers/video-file.ts @@ -172,7 +172,7 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, payload: Video // don't notify prior to scheduled video update if (!videoDatabase.ScheduleVideoUpdate) { - if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase) + if (payload.isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase) if (videoPublished) Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase) }