P2PMediaLoaderOptions,
PeertubePlayerManager,
PeertubePlayerManagerOptions,
- PlayerMode,
- WebtorrentOptions
+ PlayerMode
} from '../../../assets/player/peertube-player-manager'
@Component({
.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))
})
})
)
}
- 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
}
}
- 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,
} as P2PMediaLoaderOptions
Object.assign(options, { p2pMediaLoader })
- } else {
- mode = 'webtorrent'
}
this.zone.runOutsideAngular(async () => {
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)
}