Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

Add player mode in watch/embed urls

Chocobozzz597a9266d426
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 e1766255b2..9f3a43a08c 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 c5c46d0c5a..32bf42e125 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 7119ce0cab..04983155ce 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)
}