aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/assets/player/videojs-components/p2p-info-button.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/assets/player/videojs-components/p2p-info-button.ts')
-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 })