Skip to content

Commit

Permalink
Show/display html quality selector statically, not dynamically
Browse files Browse the repository at this point in the history
Removing the html quality selector with javascript on page load
in theory is good and ensures it will be present if plyr fails,
but it's annoying to have elements flashing when the page loads
  • Loading branch information
user234683 committed Mar 27, 2022
1 parent 0a999b2 commit 96dcefa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
6 changes: 0 additions & 6 deletions youtube/static/js/plyr-start.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,3 @@ player.eventListeners.forEach(function(eventListener) {
player.started = false;
player.once('playing', function(){this.started = true});

// Hide the external quality selector
window.addEventListener('DOMContentLoaded', function(){
var qs = document.querySelector('#quality-select');
if (qs)
qs.hidden = true;
});
12 changes: 7 additions & 5 deletions youtube/static/js/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,13 @@ if (data.using_pair_sources) {
}

// Quality selector
document.querySelector('#quality-select').addEventListener(
'change', function(e) {
changeQuality(JSON.parse(this.value))
}
);
var qualitySelector = document.querySelector('#quality-select')
if (qualitySelector)
qualitySelector.addEventListener(
'change', function(e) {
changeQuality(JSON.parse(this.value))
}
);

// Set up video start time from &t parameter
if (data.time_start != 0 && video)
Expand Down
19 changes: 10 additions & 9 deletions youtube/templates/watch.html
Original file line number Diff line number Diff line change
Expand Up @@ -515,15 +515,16 @@ <h2 class="title">{{ title }}</h2>

<div class="external-player-controls">
<input id="speed-control" type="text" title="Video speed" placeholder="Speed">

<select id="quality-select" autocomplete="off">
{% for src in uni_sources %}
<option value='{"type": "uni", "index": {{ loop.index0 }}}' {{ 'selected' if loop.index0 == uni_idx and not using_pair_sources else '' }} >{{ src['quality_string'] }}</option>
{% endfor %}
{% for src_pair in pair_sources %}
<option value='{"type": "pair", "index": {{ loop.index0}}}' {{ 'selected' if loop.index0 == pair_idx and using_pair_sources else '' }} >{{ src_pair['quality_string'] }}</option>
{% endfor %}
</select>
{% if settings.video_player == 0 %}
<select id="quality-select" autocomplete="off">
{% for src in uni_sources %}
<option value='{"type": "uni", "index": {{ loop.index0 }}}' {{ 'selected' if loop.index0 == uni_idx and not using_pair_sources else '' }} >{{ src['quality_string'] }}</option>
{% endfor %}
{% for src_pair in pair_sources %}
<option value='{"type": "pair", "index": {{ loop.index0}}}' {{ 'selected' if loop.index0 == pair_idx and using_pair_sources else '' }} >{{ src_pair['quality_string'] }}</option>
{% endfor %}
</select>
{% endif %}
</div>
<input class="checkbox" name="video_info_list" value="{{ video_info }}" form="playlist-edit" type="checkbox">

Expand Down

0 comments on commit 96dcefa

Please sign in to comment.