diff options
author | Chocobozzz <me@florianbigard.com> | 2021-12-15 16:18:05 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-12-16 10:08:55 +0100 |
commit | bf1c3c78b0e2b70bb46168a9dec0d3fa0997ab14 (patch) | |
tree | f45c657bbff59f03df3cd547f65c8119f15fd6cb /client/src/assets/player/videojs-components | |
parent | a9bfa85d2cdf13670aaced740da5b493fbeddfce (diff) | |
download | PeerTube-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.ts | 10 |
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 @@ | |||
1 | import { PlayerNetworkInfo } from '../peertube-videojs-typings' | ||
2 | import videojs from 'video.js' | 1 | import videojs from 'video.js' |
2 | import { PeerTubeP2PInfoButtonOptions, PlayerNetworkInfo } from '../peertube-videojs-typings' | ||
3 | import { bytes } from '../utils' | 3 | import { bytes } from '../utils' |
4 | 4 | ||
5 | const Button = videojs.getComponent('Button') | 5 | const Button = videojs.getComponent('Button') |
6 | class P2pInfoButton extends Button { | 6 | class 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 | }) |