mirror of https://github.com/Chocobozzz/PeerTube
Fix video resolution limit
parent
602a81a213
commit
0b755f3b27
|
@ -367,8 +367,23 @@ class PeerTubePlugin extends Plugin {
|
|||
|
||||
if (!averageDownloadSpeed) averageDownloadSpeed = this.getAndSaveActualDownloadSpeed()
|
||||
|
||||
// Limit resolution according to player height
|
||||
const playerHeight = this.playerElement.offsetHeight as number
|
||||
|
||||
// We take the first resolution just above the player height
|
||||
// Example: player height is 530px, we want the 720p file instead of 480p
|
||||
let maxResolution = this.videoFiles[0].resolution.id
|
||||
for (let i = this.videoFiles.length - 1; i >= 0; i--) {
|
||||
const resolutionId = this.videoFiles[i].resolution.id
|
||||
if (resolutionId >= playerHeight) {
|
||||
maxResolution = resolutionId
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Filter videos we can play according to our screen resolution and bandwidth
|
||||
const filteredFiles = this.videoFiles.filter(f => f.resolution.id <= this.playerElement.width)
|
||||
const filteredFiles = this.videoFiles
|
||||
.filter(f => f.resolution.id <= maxResolution)
|
||||
.filter(f => {
|
||||
const fileBitrate = (f.size / this.videoDuration)
|
||||
let threshold = fileBitrate
|
||||
|
|
Loading…
Reference in New Issue