Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added 'total downloaded' from server and peers in the player #3394

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class P2pMediaLoaderPlugin extends Plugin {
this.statsHTTPBytes.pendingUpload = []

return this.player.trigger('p2pInfo', {
source: 'p2p-media-loader',
http: {
downloadSpeed: httpDownloadSpeed,
uploadSpeed: httpUploadSpeed,
Expand Down
2 changes: 2 additions & 0 deletions client/src/assets/player/peertube-videojs-typings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@ type AutoResolutionUpdateData = {
}

type PlayerNetworkInfo = {
source: 'webtorrent' | 'p2p-media-loader'

http: {
downloadSpeed: number
uploadSpeed: number
Expand Down
13 changes: 11 additions & 2 deletions client/src/assets/player/videojs-components/p2p-info-button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,17 @@ class P2pInfoButton extends Button {
const totalUploaded = bytes(p2pStats.uploaded + httpStats.uploaded)
const numPeers = p2pStats.numPeers

subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n' +
this.player().localize('Total uploaded: ' + totalUploaded.join(' '))
subDivWebtorrent.title = this.player().localize('Total downloaded: ') + totalDownloaded.join(' ') + '\n'

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 ]
downloadSpeedUnit.textContent = ' ' + downloadSpeed[ 1 ]
Expand Down
1 change: 1 addition & 0 deletions client/src/assets/player/webtorrent/webtorrent-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ class WebTorrentPlugin extends Plugin {
if (this.webtorrent.downloadSpeed !== 0) this.downloadSpeeds.push(this.webtorrent.downloadSpeed)

return this.player.trigger('p2pInfo', {
source: 'webtorrent',
http: {
downloadSpeed: 0,
uploadSpeed: 0,
Expand Down