Hide P2P in player if disabled
This commit is contained in:
parent
a9bfa85d2c
commit
bf1c3c78b0
|
@ -320,6 +320,7 @@ export class PeertubePlayerManager {
|
||||||
controlBar: {
|
controlBar: {
|
||||||
children: this.getControlBarChildren(mode, {
|
children: this.getControlBarChildren(mode, {
|
||||||
videoShortUUID: commonOptions.videoShortUUID,
|
videoShortUUID: commonOptions.videoShortUUID,
|
||||||
|
p2pEnabled: commonOptions.p2pEnabled,
|
||||||
|
|
||||||
captions: commonOptions.captions,
|
captions: commonOptions.captions,
|
||||||
peertubeLink: commonOptions.peertubeLink,
|
peertubeLink: commonOptions.peertubeLink,
|
||||||
|
@ -452,6 +453,7 @@ export class PeertubePlayerManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static getControlBarChildren (mode: PlayerMode, options: {
|
private static getControlBarChildren (mode: PlayerMode, options: {
|
||||||
|
p2pEnabled: boolean
|
||||||
videoShortUUID: string
|
videoShortUUID: string
|
||||||
|
|
||||||
peertubeLink: boolean
|
peertubeLink: boolean
|
||||||
|
@ -527,7 +529,9 @@ export class PeertubePlayerManager {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
p2PInfoButton: {},
|
p2PInfoButton: {
|
||||||
|
p2pEnabled: options.p2pEnabled
|
||||||
|
},
|
||||||
|
|
||||||
muteToggle: {},
|
muteToggle: {},
|
||||||
volumeControl: {},
|
volumeControl: {},
|
||||||
|
|
|
@ -128,6 +128,10 @@ type PeerTubeLinkButtonOptions = {
|
||||||
shortUUID: string
|
shortUUID: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type PeerTubeP2PInfoButtonOptions = {
|
||||||
|
p2pEnabled: boolean
|
||||||
|
}
|
||||||
|
|
||||||
type WebtorrentPluginOptions = {
|
type WebtorrentPluginOptions = {
|
||||||
playerElement: HTMLVideoElement
|
playerElement: HTMLVideoElement
|
||||||
|
|
||||||
|
@ -223,5 +227,6 @@ export {
|
||||||
PeerTubeResolution,
|
PeerTubeResolution,
|
||||||
VideoJSPluginOptions,
|
VideoJSPluginOptions,
|
||||||
LoadedQualityData,
|
LoadedQualityData,
|
||||||
PeerTubeLinkButtonOptions
|
PeerTubeLinkButtonOptions,
|
||||||
|
PeerTubeP2PInfoButtonOptions
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
import { PlayerNetworkInfo } from '../peertube-videojs-typings'
|
|
||||||
import videojs from 'video.js'
|
import videojs from 'video.js'
|
||||||
|
import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
|
||||||
import { bytes } from '../utils'
|
import { bytes } from '../utils'
|
||||||
|
|
||||||
const Button = videojs.getComponent('Button')
|
const Button = videojs.getComponent('Button')
|
||||||
class P2pInfoButton extends Button {
|
class P2pInfoButton extends Button {
|
||||||
|
|
||||||
|
constructor (player: videojs.Player, options?: PeerTubeP2PInfoButtonOptions) {
|
||||||
|
super(player, options as any)
|
||||||
|
}
|
||||||
|
|
||||||
createEl () {
|
createEl () {
|
||||||
const div = videojs.dom.createEl('div', {
|
const div = videojs.dom.createEl('div', {
|
||||||
className: 'vjs-peertube'
|
className: 'vjs-peertube'
|
||||||
|
@ -14,6 +18,10 @@ class P2pInfoButton extends Button {
|
||||||
}) as HTMLDivElement
|
}) as HTMLDivElement
|
||||||
div.appendChild(subDivWebtorrent)
|
div.appendChild(subDivWebtorrent)
|
||||||
|
|
||||||
|
// Stop here if P2P is not enabled
|
||||||
|
const p2pEnabled = (this.options_ as PeerTubeP2PInfoButtonOptions).p2pEnabled
|
||||||
|
if (!p2pEnabled) return div as HTMLButtonElement
|
||||||
|
|
||||||
const downloadIcon = videojs.dom.createEl('span', {
|
const downloadIcon = videojs.dom.createEl('span', {
|
||||||
className: 'icon icon-download'
|
className: 'icon icon-download'
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user