Auto load HLS player in embed too

pull/2286/head
Chocobozzz 2019-11-22 17:16:11 +01:00
parent 3a149e9f8b
commit 0f2f274c98
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
1 changed files with 11 additions and 3 deletions

View File

@ -116,7 +116,7 @@ export class PeerTubeEmbed {
this.api.initialize()
}
private loadParams () {
private loadParams (video: VideoDetails) {
try {
const params = new URL(window.location.toString()).searchParams
@ -136,7 +136,15 @@ export class PeerTubeEmbed {
this.bigPlayBackgroundColor = this.getParamString(params, 'bigPlayBackgroundColor')
this.foregroundColor = this.getParamString(params, 'foregroundColor')
this.mode = this.getParamString(params, 'mode') === 'p2p-media-loader' ? 'p2p-media-loader' : 'webtorrent'
const modeParam = this.getParamString(params, 'mode')
if (modeParam) {
if (modeParam === 'p2p-media-loader') this.mode = 'p2p-media-loader'
else this.mode = 'webtorrent'
} else {
if (Array.isArray(video.streamingPlaylists) && video.streamingPlaylists.length !== 0) this.mode = 'p2p-media-loader'
else this.mode = 'webtorrent'
}
} catch (err) {
console.error('Cannot get params from URL.', err)
}
@ -162,7 +170,7 @@ export class PeerTubeEmbed {
const videoInfo: VideoDetails = await videoResponse.json()
const videoCaptions = await this.buildCaptions(serverTranslations, captionsResponse)
this.loadParams()
this.loadParams(videoInfo)
const options: PeertubePlayerManagerOptions = {
common: {