diff options
author | Chocobozzz <me@florianbigard.com> | 2019-01-24 10:16:30 +0100 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2019-02-11 09:13:02 +0100 |
commit | 3b6f205c34bb931de0323581edf991ca33256e6b (patch) | |
tree | f6ba40b7c666e38ff9c321906f04cb2c2630163e /client/src/assets/player/videojs-components/p2p-info-button.ts | |
parent | 2adfc7ea9a1f858db874df9fe322e7ae833db77c (diff) | |
download | PeerTube-3b6f205c34bb931de0323581edf991ca33256e6b.tar.gz PeerTube-3b6f205c34bb931de0323581edf991ca33256e6b.tar.zst PeerTube-3b6f205c34bb931de0323581edf991ca33256e6b.zip |
Correctly implement p2p-media-loader
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.ts | 16 |
1 files changed, 9 insertions, 7 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 03a5d29f0..2fc4c4562 100644 --- a/client/src/assets/player/videojs-components/p2p-info-button.ts +++ b/client/src/assets/player/videojs-components/p2p-info-button.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' | 1 | import { PlayerNetworkInfo, VideoJSComponentInterface, videojsUntyped } from '../peertube-videojs-typings' |
2 | import { bytes } from '../utils' | 2 | import { bytes } from '../utils' |
3 | 3 | ||
4 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') | 4 | const Button: VideoJSComponentInterface = videojsUntyped.getComponent('Button') |
@@ -65,7 +65,7 @@ class P2pInfoButton extends Button { | |||
65 | subDivHttp.appendChild(subDivHttpText) | 65 | subDivHttp.appendChild(subDivHttpText) |
66 | div.appendChild(subDivHttp) | 66 | div.appendChild(subDivHttp) |
67 | 67 | ||
68 | this.player_.on('p2pInfo', (event: any, data: any) => { | 68 | this.player_.on('p2pInfo', (event: any, data: PlayerNetworkInfo) => { |
69 | // We are in HTTP fallback | 69 | // We are in HTTP fallback |
70 | if (!data) { | 70 | if (!data) { |
71 | subDivHttp.className = 'vjs-peertube-displayed' | 71 | subDivHttp.className = 'vjs-peertube-displayed' |
@@ -74,11 +74,13 @@ class P2pInfoButton extends Button { | |||
74 | return | 74 | return |
75 | } | 75 | } |
76 | 76 | ||
77 | const downloadSpeed = bytes(data.downloadSpeed) | 77 | const p2pStats = data.p2p |
78 | const uploadSpeed = bytes(data.uploadSpeed) | 78 | |
79 | const totalDownloaded = bytes(data.downloaded) | 79 | const downloadSpeed = bytes(p2pStats.downloadSpeed) |
80 | const totalUploaded = bytes(data.uploaded) | 80 | const uploadSpeed = bytes(p2pStats.uploadSpeed) |
81 | const numPeers = data.numPeers | 81 | const totalDownloaded = bytes(p2pStats.downloaded) |
82 | const totalUploaded = bytes(p2pStats.uploaded) | ||
83 | const numPeers = p2pStats.numPeers | ||
82 | 84 | ||
83 | subDivWebtorrent.title = this.player_.localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' + | 85 | subDivWebtorrent.title = this.player_.localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' + |
84 | this.player_.localize('Total uploaded: ' + totalUploaded.join(' ')) | 86 | this.player_.localize('Total uploaded: ' + totalUploaded.join(' ')) |