mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
parent
06bac4edf0
commit
3dec3744f0
1 changed files with 14 additions and 0 deletions
|
@ -485,16 +485,30 @@ export default {
|
||||||
if (qualityConds) {
|
if (qualityConds) {
|
||||||
var leastDiff = Number.MAX_VALUE;
|
var leastDiff = Number.MAX_VALUE;
|
||||||
var bestStream = null;
|
var bestStream = null;
|
||||||
|
|
||||||
|
var bestAudio = 0;
|
||||||
|
|
||||||
|
// Choose the best audio stream
|
||||||
|
if (qualityConds >= 480)
|
||||||
|
player.getVariantTracks().forEach(track => {
|
||||||
|
const audioBandwidth = track.audioBandwidth;
|
||||||
|
if (audioBandwidth > bestAudio) bestAudio = audioBandwidth;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find best matching stream based on resolution and bitrate
|
||||||
player
|
player
|
||||||
.getVariantTracks()
|
.getVariantTracks()
|
||||||
.sort((a, b) => a.bandwidth - b.bandwidth)
|
.sort((a, b) => a.bandwidth - b.bandwidth)
|
||||||
.forEach(stream => {
|
.forEach(stream => {
|
||||||
|
if (stream.audioBandwidth < bestAudio) return;
|
||||||
|
|
||||||
const diff = Math.abs(quality - stream.height);
|
const diff = Math.abs(quality - stream.height);
|
||||||
if (diff < leastDiff) {
|
if (diff < leastDiff) {
|
||||||
leastDiff = diff;
|
leastDiff = diff;
|
||||||
bestStream = stream;
|
bestStream = stream;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
player.selectVariantTrack(bestStream);
|
player.selectVariantTrack(bestStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue