mirror of https://github.com/Chocobozzz/PeerTube
add 'total downloaded' stats from server and peers in player (#3394)
Implements https://github.com/Chocobozzz/PeerTube/issues/3384 This will only work with HLS. The display for Webtorrent is left untouched. Co-authored-by: Rigel Kent <par@rigelk.eu>pull/3401/head
parent
f8b530e0a5
commit
171528373e
|
@ -153,6 +153,7 @@ class P2pMediaLoaderPlugin extends Plugin {
|
||||||
this.statsHTTPBytes.pendingUpload = []
|
this.statsHTTPBytes.pendingUpload = []
|
||||||
|
|
||||||
return this.player.trigger('p2pInfo', {
|
return this.player.trigger('p2pInfo', {
|
||||||
|
source: 'p2p-media-loader',
|
||||||
http: {
|
http: {
|
||||||
downloadSpeed: httpDownloadSpeed,
|
downloadSpeed: httpDownloadSpeed,
|
||||||
uploadSpeed: httpUploadSpeed,
|
uploadSpeed: httpUploadSpeed,
|
||||||
|
|
|
@ -175,6 +175,8 @@ type AutoResolutionUpdateData = {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PlayerNetworkInfo = {
|
type PlayerNetworkInfo = {
|
||||||
|
source: 'webtorrent' | 'p2p-media-loader'
|
||||||
|
|
||||||
http: {
|
http: {
|
||||||
downloadSpeed: number
|
downloadSpeed: number
|
||||||
uploadSpeed: number
|
uploadSpeed: number
|
||||||
|
|
|
@ -84,8 +84,17 @@ class P2pInfoButton extends Button {
|
||||||
const totalUploaded = bytes(p2pStats.uploaded + httpStats.uploaded)
|
const totalUploaded = bytes(p2pStats.uploaded + httpStats.uploaded)
|
||||||
const numPeers = p2pStats.numPeers
|
const numPeers = p2pStats.numPeers
|
||||||
|
|
||||||
subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' +
|
subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n'
|
||||||
this.player().localize('Total uploaded: ' + totalUploaded.join(' '))
|
|
||||||
|
if (data.source === 'p2p-media-loader') {
|
||||||
|
const downloadedFromServer = bytes(httpStats.downloaded).join(' ')
|
||||||
|
const downloadedFromPeers = bytes(p2pStats.downloaded).join(' ')
|
||||||
|
|
||||||
|
subDivWebtorrent.title +=
|
||||||
|
'* ' + this.player().localize('From the server: ') + downloadedFromServer + '\n' +
|
||||||
|
'* ' + this.player().localize('From peers: ') + downloadedFromPeers + '\n'
|
||||||
|
}
|
||||||
|
subDivWebtorrent.title += this.player().localize('Total uploaded: ') + totalUploaded.join(' ')
|
||||||
|
|
||||||
downloadSpeedNumber.textContent = downloadSpeed[ 0 ]
|
downloadSpeedNumber.textContent = downloadSpeed[ 0 ]
|
||||||
downloadSpeedUnit.textContent = ' ' + downloadSpeed[ 1 ]
|
downloadSpeedUnit.textContent = ' ' + downloadSpeed[ 1 ]
|
||||||
|
|
|
@ -487,6 +487,7 @@ class WebTorrentPlugin extends Plugin {
|
||||||
if (this.webtorrent.downloadSpeed !== 0) this.downloadSpeeds.push(this.webtorrent.downloadSpeed)
|
if (this.webtorrent.downloadSpeed !== 0) this.downloadSpeeds.push(this.webtorrent.downloadSpeed)
|
||||||
|
|
||||||
return this.player.trigger('p2pInfo', {
|
return this.player.trigger('p2pInfo', {
|
||||||
|
source: 'webtorrent',
|
||||||
http: {
|
http: {
|
||||||
downloadSpeed: 0,
|
downloadSpeed: 0,
|
||||||
uploadSpeed: 0,
|
uploadSpeed: 0,
|
||||||
|
|
Loading…
Reference in New Issue