mirror of
https://github.com/mmjee/Piped-Material.git
synced 2024-12-06 19:26:36 +01:00
Port "Choose best audio quality on streams >= 480p."
See https://github.com/TeamPiped/Piped/commit/3dec3744f01745713ca7d45ce26a0537c182ef8f
This commit is contained in:
@@ -246,16 +246,29 @@ export default {
|
||||
if (qualityConds) {
|
||||
let leastDiff = Number.MAX_VALUE
|
||||
let bestStream = null
|
||||
|
||||
let bestAudio = 0
|
||||
// Choose the best audio stream
|
||||
if (qualityConds >= 480) {
|
||||
player.getVariantTracks().forEach(track => {
|
||||
const audioBandwidth = track.audioBandwidth
|
||||
if (audioBandwidth > bestAudio) bestAudio = audioBandwidth
|
||||
})
|
||||
}
|
||||
|
||||
player
|
||||
.getVariantTracks()
|
||||
.sort((a, b) => a.bandwidth - b.bandwidth)
|
||||
.forEach(stream => {
|
||||
if (stream.audioBandwidth < bestAudio) return
|
||||
|
||||
const diff = Math.abs(quality - stream.height)
|
||||
if (diff < leastDiff) {
|
||||
leastDiff = diff
|
||||
bestStream = stream
|
||||
}
|
||||
})
|
||||
|
||||
player.selectVariantTrack(bestStream)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user