Add ability to disable p2p in embed with URL
This commit is contained in:
parent
b65de1be4d
commit
8530211822
|
@ -216,10 +216,17 @@
|
||||||
></my-peertube-checkbox>
|
></my-peertube-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<my-peertube-checkbox
|
||||||
|
inputName="embedP2P" [(ngModel)]="customizations.embedP2P"
|
||||||
|
i18n-labelText labelText="P2P"
|
||||||
|
></my-peertube-checkbox>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<my-peertube-checkbox
|
<my-peertube-checkbox
|
||||||
inputName="warningTitle" [(ngModel)]="customizations.warningTitle"
|
inputName="warningTitle" [(ngModel)]="customizations.warningTitle"
|
||||||
i18n-labelText labelText="Display privacy warning"
|
i18n-labelText labelText="Display privacy warning" [disabled]="!customizations.embedP2P"
|
||||||
></my-peertube-checkbox>
|
></my-peertube-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -232,7 +239,7 @@
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<my-peertube-checkbox
|
<my-peertube-checkbox
|
||||||
inputName="controls" [(ngModel)]="customizations.peertubeLink"
|
inputName="peertubeLink" [(ngModel)]="customizations.peertubeLink"
|
||||||
i18n-labelText labelText="Display PeerTube button link"
|
i18n-labelText labelText="Display PeerTube button link"
|
||||||
></my-peertube-checkbox>
|
></my-peertube-checkbox>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import { Component, ElementRef, Input, ViewChild } from '@angular/core'
|
import { Component, ElementRef, Input, ViewChild } from '@angular/core'
|
||||||
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
|
import { DomSanitizer, SafeHtml } from '@angular/platform-browser'
|
||||||
|
import { ServerService } from '@app/core'
|
||||||
import { VideoDetails } from '@app/shared/shared-main'
|
import { VideoDetails } from '@app/shared/shared-main'
|
||||||
import { VideoPlaylist } from '@app/shared/shared-video-playlist'
|
import { VideoPlaylist } from '@app/shared/shared-video-playlist'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
|
@ -21,6 +22,8 @@ type Customizations = {
|
||||||
originUrl: boolean
|
originUrl: boolean
|
||||||
autoplay: boolean
|
autoplay: boolean
|
||||||
muted: boolean
|
muted: boolean
|
||||||
|
|
||||||
|
embedP2P: boolean
|
||||||
title: boolean
|
title: boolean
|
||||||
warningTitle: boolean
|
warningTitle: boolean
|
||||||
controls: boolean
|
controls: boolean
|
||||||
|
@ -54,7 +57,8 @@ export class VideoShareComponent {
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private modalService: NgbModal,
|
private modalService: NgbModal,
|
||||||
private sanitizer: DomSanitizer
|
private sanitizer: DomSanitizer,
|
||||||
|
private server: ServerService
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) {
|
show (currentVideoTimestamp?: number, currentPlaylistPosition?: number) {
|
||||||
|
@ -78,6 +82,8 @@ export class VideoShareComponent {
|
||||||
autoplay: false,
|
autoplay: false,
|
||||||
muted: false,
|
muted: false,
|
||||||
|
|
||||||
|
embedP2P: this.server.getHTMLConfig().defaults.p2p.embed.enabled,
|
||||||
|
|
||||||
// Embed options
|
// Embed options
|
||||||
title: true,
|
title: true,
|
||||||
warningTitle: true,
|
warningTitle: true,
|
||||||
|
@ -87,6 +93,11 @@ export class VideoShareComponent {
|
||||||
set: (target, prop, value) => {
|
set: (target, prop, value) => {
|
||||||
target[prop] = value
|
target[prop] = value
|
||||||
|
|
||||||
|
if (prop === 'embedP2P') {
|
||||||
|
// Auto enabled warning title if P2P is enabled
|
||||||
|
this.customizations.warningTitle = value
|
||||||
|
}
|
||||||
|
|
||||||
this.updateEmbedCode()
|
this.updateEmbedCode()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -101,7 +112,7 @@ export class VideoShareComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
getVideoIframeCode () {
|
getVideoIframeCode () {
|
||||||
const embedUrl = decorateVideoLink({ url: this.video.embedUrl, ...this.getVideoOptions() })
|
const embedUrl = decorateVideoLink({ url: this.video.embedUrl, ...this.getVideoOptions(true) })
|
||||||
|
|
||||||
return buildVideoOrPlaylistEmbed(embedUrl, this.video.name)
|
return buildVideoOrPlaylistEmbed(embedUrl, this.video.name)
|
||||||
}
|
}
|
||||||
|
@ -120,7 +131,7 @@ export class VideoShareComponent {
|
||||||
return decorateVideoLink({
|
return decorateVideoLink({
|
||||||
url,
|
url,
|
||||||
|
|
||||||
...this.getVideoOptions()
|
...this.getVideoOptions(false)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,7 +176,21 @@ export class VideoShareComponent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private getVideoOptions () {
|
private getVideoOptions (forEmbed: boolean) {
|
||||||
|
const embedOptions = forEmbed
|
||||||
|
? {
|
||||||
|
title: this.customizations.title,
|
||||||
|
warningTitle: this.customizations.warningTitle,
|
||||||
|
controls: this.customizations.controls,
|
||||||
|
peertubeLink: this.customizations.peertubeLink,
|
||||||
|
|
||||||
|
// If using default value, we don't need to specify it
|
||||||
|
p2p: this.customizations.embedP2P === this.server.getHTMLConfig().defaults.p2p.embed.enabled
|
||||||
|
? undefined
|
||||||
|
: this.customizations.embedP2P
|
||||||
|
}
|
||||||
|
: {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined,
|
startTime: this.customizations.startAtCheckbox ? this.customizations.startAt : undefined,
|
||||||
stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined,
|
stopTime: this.customizations.stopAtCheckbox ? this.customizations.stopAt : undefined,
|
||||||
|
@ -176,10 +201,7 @@ export class VideoShareComponent {
|
||||||
autoplay: this.customizations.autoplay,
|
autoplay: this.customizations.autoplay,
|
||||||
muted: this.customizations.muted,
|
muted: this.customizations.muted,
|
||||||
|
|
||||||
title: this.customizations.title,
|
...embedOptions
|
||||||
warningTitle: this.customizations.warningTitle,
|
|
||||||
controls: this.customizations.controls,
|
|
||||||
peertubeLink: this.customizations.peertubeLink
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,6 @@ class StatsCard extends Component {
|
||||||
updateInterval: any
|
updateInterval: any
|
||||||
|
|
||||||
mode: 'webtorrent' | 'p2p-media-loader'
|
mode: 'webtorrent' | 'p2p-media-loader'
|
||||||
p2pEnabled: boolean
|
|
||||||
|
|
||||||
metadataStore: any = {}
|
metadataStore: any = {}
|
||||||
|
|
||||||
|
@ -211,7 +210,7 @@ class StatsCard extends Component {
|
||||||
|
|
||||||
return `
|
return `
|
||||||
${this.buildElement(player.localize('Player mode'), this.mode || 'HTTP')}
|
${this.buildElement(player.localize('Player mode'), this.mode || 'HTTP')}
|
||||||
${this.buildElement(player.localize('P2P'), player.localize(this.p2pEnabled ? 'enabled' : 'disabled'))}
|
${this.buildElement(player.localize('P2P'), player.localize(this.options_.p2pEnabled ? 'enabled' : 'disabled'))}
|
||||||
|
|
||||||
${this.buildElement(player.localize('Video UUID'), this.options_.videoUUID)}
|
${this.buildElement(player.localize('Video UUID'), this.options_.videoUUID)}
|
||||||
|
|
||||||
|
|
|
@ -45,6 +45,7 @@ export class PeerTubeEmbed {
|
||||||
title: boolean
|
title: boolean
|
||||||
warningTitle: boolean
|
warningTitle: boolean
|
||||||
peertubeLink: boolean
|
peertubeLink: boolean
|
||||||
|
p2pEnabled: boolean
|
||||||
bigPlayBackgroundColor: string
|
bigPlayBackgroundColor: string
|
||||||
foregroundColor: string
|
foregroundColor: string
|
||||||
|
|
||||||
|
@ -284,6 +285,7 @@ export class PeerTubeEmbed {
|
||||||
this.enableApi = this.getParamToggle(params, 'api', this.enableApi)
|
this.enableApi = this.getParamToggle(params, 'api', this.enableApi)
|
||||||
this.warningTitle = this.getParamToggle(params, 'warningTitle', true)
|
this.warningTitle = this.getParamToggle(params, 'warningTitle', true)
|
||||||
this.peertubeLink = this.getParamToggle(params, 'peertubeLink', true)
|
this.peertubeLink = this.getParamToggle(params, 'peertubeLink', true)
|
||||||
|
this.p2pEnabled = this.getParamToggle(params, 'p2p', this.isP2PEnabled(video))
|
||||||
|
|
||||||
this.scope = this.getParamString(params, 'scope', this.scope)
|
this.scope = this.getParamString(params, 'scope', this.scope)
|
||||||
this.subtitle = this.getParamString(params, 'subtitle')
|
this.subtitle = this.getParamString(params, 'subtitle')
|
||||||
|
@ -518,7 +520,7 @@ export class PeerTubeEmbed {
|
||||||
muted: this.muted,
|
muted: this.muted,
|
||||||
loop: this.loop,
|
loop: this.loop,
|
||||||
|
|
||||||
p2pEnabled: this.isP2PEnabled(videoInfo),
|
p2pEnabled: this.p2pEnabled,
|
||||||
|
|
||||||
captions: videoCaptions.length !== 0,
|
captions: videoCaptions.length !== 0,
|
||||||
subtitle: this.subtitle,
|
subtitle: this.subtitle,
|
||||||
|
@ -674,7 +676,7 @@ export class PeerTubeEmbed {
|
||||||
|
|
||||||
const title = this.title ? videoInfo.name : undefined
|
const title = this.title ? videoInfo.name : undefined
|
||||||
|
|
||||||
const description = this.warningTitle && this.isP2PEnabled(videoInfo)
|
const description = this.warningTitle && this.p2pEnabled
|
||||||
? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
|
? '<span class="text">' + peertubeTranslate('Watching this video may reveal your IP address to others.') + '</span>'
|
||||||
: undefined
|
: undefined
|
||||||
|
|
||||||
|
|
|
@ -50,6 +50,7 @@ function decorateVideoLink (options: {
|
||||||
warningTitle?: boolean
|
warningTitle?: boolean
|
||||||
controls?: boolean
|
controls?: boolean
|
||||||
peertubeLink?: boolean
|
peertubeLink?: boolean
|
||||||
|
p2p?: boolean
|
||||||
}) {
|
}) {
|
||||||
const { url } = options
|
const { url } = options
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ function decorateVideoLink (options: {
|
||||||
if (options.warningTitle === false) params.set('warningTitle', '0')
|
if (options.warningTitle === false) params.set('warningTitle', '0')
|
||||||
if (options.controls === false) params.set('controls', '0')
|
if (options.controls === false) params.set('controls', '0')
|
||||||
if (options.peertubeLink === false) params.set('peertubeLink', '0')
|
if (options.peertubeLink === false) params.set('peertubeLink', '0')
|
||||||
|
if (options.p2p !== undefined) params.set('p2p', options.p2p ? '1' : '0')
|
||||||
|
|
||||||
return buildUrl(url, params)
|
return buildUrl(url, params)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue