diff options
Diffstat (limited to 'youtube/static/js/watch.dash.js')
| -rw-r--r-- | youtube/static/js/watch.dash.js | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/youtube/static/js/watch.dash.js b/youtube/static/js/watch.dash.js index cb02421..5bbc7a2 100644 --- a/youtube/static/js/watch.dash.js +++ b/youtube/static/js/watch.dash.js @@ -31,9 +31,34 @@ if (data.using_pair_sources) { avMerge = new AVMerge(video, srcPair, 0); } -// Quality selector +// Quality selector — populate with available sources const qs = document.getElementById('quality-select'); if (qs) { + // Clear the HLS-oriented "Auto" default; DASH has discrete sources + qs.innerHTML = ''; + + // Add pair_sources (video+audio, used by AVMerge) + if (data['pair_sources'] && data['pair_sources'].length) { + data['pair_sources'].forEach(function(src, i) { + let opt = document.createElement('option'); + opt.value = JSON.stringify({type: 'pair', index: i}); + opt.textContent = src.quality_string; + if (i === data['pair_idx']) opt.selected = true; + qs.appendChild(opt); + }); + } + + // Add uni_sources (integrated video+audio, single file) + if (data['uni_sources'] && data['uni_sources'].length) { + data['uni_sources'].forEach(function(src, i) { + let opt = document.createElement('option'); + opt.value = JSON.stringify({type: 'uni', index: i}); + opt.textContent = src.quality_string; + if (!data['pair_sources'].length && i === data['uni_idx']) opt.selected = true; + qs.appendChild(opt); + }); + } + qs.addEventListener('change', function(e) { changeQuality(JSON.parse(this.value)) }); |
