Add P2P enabled/disabled in player card

This commit is contained in:
Chocobozzz 2021-12-15 16:25:33 +01:00
parent bf1c3c78b0
commit 9576506763
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
3 changed files with 9 additions and 2 deletions

View File

@ -193,7 +193,8 @@ export class PeertubePlayerManager {
player.stats({ player.stats({
videoUUID: options.common.videoUUID, videoUUID: options.common.videoUUID,
videoIsLive: options.common.isLive, videoIsLive: options.common.isLive,
mode mode,
p2pEnabled: options.common.p2pEnabled
}) })
player.on('p2pInfo', (_, data: PlayerNetworkInfo) => { player.on('p2pInfo', (_, data: PlayerNetworkInfo) => {

View File

@ -7,6 +7,7 @@ interface StatsCardOptions extends videojs.ComponentOptions {
videoUUID: string videoUUID: string
videoIsLive: boolean videoIsLive: boolean
mode: 'webtorrent' | 'p2p-media-loader' mode: 'webtorrent' | 'p2p-media-loader'
p2pEnabled: boolean
} }
interface PlayerNetworkInfo { interface PlayerNetworkInfo {
@ -33,6 +34,7 @@ class StatsCard extends Component {
updateInterval: any updateInterval: any
mode: 'webtorrent' | 'p2p-media-loader' mode: 'webtorrent' | 'p2p-media-loader'
p2pEnabled: boolean
metadataStore: any = {} metadataStore: any = {}
@ -200,7 +202,7 @@ class StatsCard extends Component {
? `${playerNetworkInfo.totalDownloaded} ⇓ / ${playerNetworkInfo.totalUploaded} ⇑` ? `${playerNetworkInfo.totalDownloaded} ⇓ / ${playerNetworkInfo.totalUploaded} ⇑`
: undefined : undefined
const downloadBreakdown = playerNetworkInfo.downloadedFromServer const downloadBreakdown = playerNetworkInfo.downloadedFromServer
? `${playerNetworkInfo.downloadedFromServer} from server · ${playerNetworkInfo.downloadedFromPeers} from peers` ? `${playerNetworkInfo.downloadedFromServer} from servers · ${playerNetworkInfo.downloadedFromPeers} from peers`
: undefined : undefined
const bufferProgress = progress !== undefined const bufferProgress = progress !== undefined
@ -209,6 +211,7 @@ class StatsCard extends Component {
return ` return `
${this.buildElement(player.localize('Player mode'), this.mode || 'HTTP')} ${this.buildElement(player.localize('Player mode'), this.mode || 'HTTP')}
${this.buildElement(player.localize('P2P'), player.localize(this.p2pEnabled ? 'enabled' : 'disabled'))}
${this.buildElement(player.localize('Video UUID'), this.options_.videoUUID)} ${this.buildElement(player.localize('Video UUID'), this.options_.videoUUID)}

View File

@ -51,6 +51,9 @@ const playerKeys = {
'Buffer Progress': 'Buffer Progress', 'Buffer Progress': 'Buffer Progress',
'Buffer State': 'Buffer State', 'Buffer State': 'Buffer State',
'Live Latency': 'Live Latency', 'Live Latency': 'Live Latency',
'P2P': 'P2P',
'enabled': 'enabled',
'disabled': 'disabled',
' off': ' off', ' off': ' off',
'Player mode': 'Player mode' 'Player mode': 'Player mode'
} }