mirror of
https://github.com/TeamPiped/Piped.git
synced 2024-08-14 23:57:27 +00:00
Filter audio tracks in variants too.
This commit is contained in:
parent
5a268b26bd
commit
455edfcf7c
1 changed files with 15 additions and 4 deletions
|
@ -488,7 +488,15 @@ export default {
|
||||||
|
|
||||||
player.load(uri, 0, mime).then(() => {
|
player.load(uri, 0, mime).then(() => {
|
||||||
// Set the audio language
|
// Set the audio language
|
||||||
player.selectAudioLanguage(this.getPreferenceString("hl", "en").substr(0, 2));
|
const prefLang = this.getPreferenceString("hl", "en").substr(0, 2);
|
||||||
|
var lang = "en";
|
||||||
|
for (var l in player.getAudioLanguages()) {
|
||||||
|
if (l == prefLang) {
|
||||||
|
lang = l;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
player.selectAudioLanguage(lang);
|
||||||
|
|
||||||
if (qualityConds) {
|
if (qualityConds) {
|
||||||
var leastDiff = Number.MAX_VALUE;
|
var leastDiff = Number.MAX_VALUE;
|
||||||
|
@ -496,16 +504,19 @@ export default {
|
||||||
|
|
||||||
var bestAudio = 0;
|
var bestAudio = 0;
|
||||||
|
|
||||||
|
const tracks = player
|
||||||
|
.getVariantTracks()
|
||||||
|
.filter(track => track.language == lang || track.language == "und");
|
||||||
|
|
||||||
// Choose the best audio stream
|
// Choose the best audio stream
|
||||||
if (quality >= 480)
|
if (quality >= 480)
|
||||||
player.getVariantTracks().forEach(track => {
|
tracks.forEach(track => {
|
||||||
const audioBandwidth = track.audioBandwidth;
|
const audioBandwidth = track.audioBandwidth;
|
||||||
if (audioBandwidth > bestAudio) bestAudio = audioBandwidth;
|
if (audioBandwidth > bestAudio) bestAudio = audioBandwidth;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find best matching stream based on resolution and bitrate
|
// Find best matching stream based on resolution and bitrate
|
||||||
player
|
tracks
|
||||||
.getVariantTracks()
|
|
||||||
.sort((a, b) => a.bandwidth - b.bandwidth)
|
.sort((a, b) => a.bandwidth - b.bandwidth)
|
||||||
.forEach(stream => {
|
.forEach(stream => {
|
||||||
if (stream.audioBandwidth < bestAudio) return;
|
if (stream.audioBandwidth < bestAudio) return;
|
||||||
|
|
Loading…
Reference in a new issue