mirror of https://github.com/Chocobozzz/PeerTube
Add player mode in watch/embed urls
parent
4c280004ce
commit
597a9266d4
|
@ -27,8 +27,7 @@ import {
|
||||||
P2PMediaLoaderOptions,
|
P2PMediaLoaderOptions,
|
||||||
PeertubePlayerManager,
|
PeertubePlayerManager,
|
||||||
PeertubePlayerManagerOptions,
|
PeertubePlayerManagerOptions,
|
||||||
PlayerMode,
|
PlayerMode
|
||||||
WebtorrentOptions
|
|
||||||
} from '../../../assets/player/peertube-player-manager'
|
} from '../../../assets/player/peertube-player-manager'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -117,8 +116,9 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
.subscribe(([ video, captionsResult ]) => {
|
.subscribe(([ video, captionsResult ]) => {
|
||||||
const startTime = this.route.snapshot.queryParams.start
|
const startTime = this.route.snapshot.queryParams.start
|
||||||
const subtitle = this.route.snapshot.queryParams.subtitle
|
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))
|
.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
|
this.video = video
|
||||||
|
|
||||||
// Re init attributes
|
// Re init attributes
|
||||||
|
@ -440,10 +444,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mode: PlayerMode
|
const mode: PlayerMode = urlOptions.playerMode === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent'
|
||||||
|
|
||||||
|
if (mode === 'p2p-media-loader') {
|
||||||
const hlsPlaylist = this.video.getHlsPlaylist()
|
const hlsPlaylist = this.video.getHlsPlaylist()
|
||||||
if (hlsPlaylist) {
|
|
||||||
mode = 'p2p-media-loader'
|
|
||||||
|
|
||||||
const p2pMediaLoader = {
|
const p2pMediaLoader = {
|
||||||
playlistUrl: hlsPlaylist.playlistUrl,
|
playlistUrl: hlsPlaylist.playlistUrl,
|
||||||
|
@ -454,8 +458,6 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
|
||||||
} as P2PMediaLoaderOptions
|
} as P2PMediaLoaderOptions
|
||||||
|
|
||||||
Object.assign(options, { p2pMediaLoader })
|
Object.assign(options, { p2pMediaLoader })
|
||||||
} else {
|
|
||||||
mode = 'webtorrent'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.zone.runOutsideAngular(async () => {
|
this.zone.runOutsideAngular(async () => {
|
||||||
|
|
|
@ -263,7 +263,7 @@ class PeerTubeEmbed {
|
||||||
this.subtitle = this.getParamString(params, 'subtitle')
|
this.subtitle = this.getParamString(params, 'subtitle')
|
||||||
this.startTime = this.getParamString(params, 'start')
|
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) {
|
} catch (err) {
|
||||||
console.error('Cannot get params from URL.', err)
|
console.error('Cannot get params from URL.', err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ async function onVideoFileOptimizerSuccess (videoArg: VideoModel, payload: Video
|
||||||
|
|
||||||
// don't notify prior to scheduled video update
|
// don't notify prior to scheduled video update
|
||||||
if (!videoDatabase.ScheduleVideoUpdate) {
|
if (!videoDatabase.ScheduleVideoUpdate) {
|
||||||
if (isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
|
if (payload.isNewVideo) Notifier.Instance.notifyOnNewVideo(videoDatabase)
|
||||||
if (videoPublished) Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase)
|
if (videoPublished) Notifier.Instance.notifyOnPendingVideoPublished(videoDatabase)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue