mirror of https://github.com/Chocobozzz/PeerTube
Hide P2P in player if disabled
parent
a9bfa85d2c
commit
bf1c3c78b0
|
@ -320,6 +320,7 @@ export class PeertubePlayerManager {
|
|||
controlBar: {
|
||||
children: this.getControlBarChildren(mode, {
|
||||
videoShortUUID: commonOptions.videoShortUUID,
|
||||
p2pEnabled: commonOptions.p2pEnabled,
|
||||
|
||||
captions: commonOptions.captions,
|
||||
peertubeLink: commonOptions.peertubeLink,
|
||||
|
@ -452,6 +453,7 @@ export class PeertubePlayerManager {
|
|||
}
|
||||
|
||||
private static getControlBarChildren (mode: PlayerMode, options: {
|
||||
p2pEnabled: boolean
|
||||
videoShortUUID: string
|
||||
|
||||
peertubeLink: boolean
|
||||
|
@ -527,7 +529,9 @@ export class PeertubePlayerManager {
|
|||
}
|
||||
},
|
||||
|
||||
p2PInfoButton: {},
|
||||
p2PInfoButton: {
|
||||
p2pEnabled: options.p2pEnabled
|
||||
},
|
||||
|
||||
muteToggle: {},
|
||||
volumeControl: {},
|
||||
|
|
|
@ -128,6 +128,10 @@ type PeerTubeLinkButtonOptions = {
|
|||
shortUUID: string
|
||||
}
|
||||
|
||||
type PeerTubeP2PInfoButtonOptions = {
|
||||
p2pEnabled: boolean
|
||||
}
|
||||
|
||||
type WebtorrentPluginOptions = {
|
||||
playerElement: HTMLVideoElement
|
||||
|
||||
|
@ -223,5 +227,6 @@ export {
|
|||
PeerTubeResolution,
|
||||
VideoJSPluginOptions,
|
||||
LoadedQualityData,
|
||||
PeerTubeLinkButtonOptions
|
||||
PeerTubeLinkButtonOptions,
|
||||
PeerTubeP2PInfoButtonOptions
|
||||
}
|
||||
|
|
|
@ -1,10 +1,14 @@
|
|||
import { PlayerNetworkInfo } from '../peertube-videojs-typings'
|
||||
import videojs from 'video.js'
|
||||
import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
|
||||
import { bytes } from '../utils'
|
||||
|
||||
const Button = videojs.getComponent('Button')
|
||||
class P2pInfoButton extends Button {
|
||||
|
||||
constructor (player: videojs.Player, options?: PeerTubeP2PInfoButtonOptions) {
|
||||
super(player, options as any)
|
||||
}
|
||||
|
||||
createEl () {
|
||||
const div = videojs.dom.createEl('div', {
|
||||
className: 'vjs-peertube'
|
||||
|
@ -14,6 +18,10 @@ class P2pInfoButton extends Button {
|
|||
}) as HTMLDivElement
|
||||
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', {
|
||||
className: 'icon icon-download'
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue