Add player mode in watch/embed urls

pull/1625/head
Chocobozzz 2019-02-07 15:56:17 +01:00 committed by Chocobozzz
parent 4c280004ce
commit 597a9266d4
3 changed files with 14 additions and 12 deletions

View File

@ -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 () => {

View File

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

View File

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