From bf1c3c78b0e2b70bb46168a9dec0d3fa0997ab14 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 15 Dec 2021 16:18:05 +0100 Subject: Hide P2P in player if disabled --- client/src/assets/player/videojs-components/p2p-info-button.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'client/src/assets/player/videojs-components') diff --git a/client/src/assets/player/videojs-components/p2p-info-button.ts b/client/src/assets/player/videojs-components/p2p-info-button.ts index 07ed18989..081dee1d3 100644 --- a/client/src/assets/player/videojs-components/p2p-info-button.ts +++ b/client/src/assets/player/videojs-components/p2p-info-button.ts @@ -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' }) -- cgit v1.2.3