aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/videojs-components
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-12-15 16:18:05 +0100
committerChocobozzz <me@florianbigard.com>2021-12-16 10:08:55 +0100
commitbf1c3c78b0e2b70bb46168a9dec0d3fa0997ab14 (patch)
treef45c657bbff59f03df3cd547f65c8119f15fd6cb /client/src/assets/player/videojs-components
parenta9bfa85d2cdf13670aaced740da5b493fbeddfce (diff)
downloadPeerTube-bf1c3c78b0e2b70bb46168a9dec0d3fa0997ab14.tar.gz
PeerTube-bf1c3c78b0e2b70bb46168a9dec0d3fa0997ab14.tar.zst
PeerTube-bf1c3c78b0e2b70bb46168a9dec0d3fa0997ab14.zip
Hide P2P in player if disabled
Diffstat (limited to 'client/src/assets/player/videojs-components')
-rw-r--r--client/src/assets/player/videojs-components/p2p-info-button.ts10
1 files changed, 9 insertions, 1 deletions
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 @@
1import { PlayerNetworkInfo } from '../peertube-videojs-typings'
2import videojs from 'video.js' 1import videojs from 'video.js'
2import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../peertube-videojs-typings'
3import { bytes } from '../utils' 3import { bytes } from '../utils'
4 4
5const Button = videojs.getComponent('Button') 5const Button = videojs.getComponent('Button')
6class P2pInfoButton extends Button { 6class P2pInfoButton extends Button {
7 7
8 constructor (player: videojs.Player, options?: PeerTubeP2PInfoButtonOptions) {
9 super(player, options as any)
10 }
11
8 createEl () { 12 createEl () {
9 const div = videojs.dom.createEl('div', { 13 const div = videojs.dom.createEl('div', {
10 className: 'vjs-peertube' 14 className: 'vjs-peertube'
@@ -14,6 +18,10 @@ class P2pInfoButton extends Button {
14 }) as HTMLDivElement 18 }) as HTMLDivElement
15 div.appendChild(subDivWebtorrent) 19 div.appendChild(subDivWebtorrent)
16 20
21 // Stop here if P2P is not enabled
22 const p2pEnabled = (this.options_ as PeerTubeP2PInfoButtonOptions).p2pEnabled
23 if (!p2pEnabled) return div as HTMLButtonElement
24
17 const downloadIcon = videojs.dom.createEl('span', { 25 const downloadIcon = videojs.dom.createEl('span', {
18 className: 'icon icon-download' 26 className: 'icon icon-download'
19 }) 27 })