Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update player.js finish fixing player_quality #2458

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions _locales/el/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@
"block_Codec_Alert_h264": {
"message": "Χρειάζεστε είτε το H.264 είτε το VP9 ενεργοποιημένο για να αναπαραχθούν βίντεο στο Youtube."
},
"block_Codec_Alert_VP9": {
"message": "Χρειάζεστε είτε το VP9 είτε το H.264 ενεργοποιημένο για να αναπαραχθούν βίντεο στο Youtube."
},
"blockAll": {
"message": "Απενεργοποίηση (Αποκλεισμός ή Παράβλεψη)"
},
Expand Down Expand Up @@ -1264,4 +1261,4 @@
"Youtube_Search": {
"message": "Youtube-Αναζήτηση"
}
}
}
3 changes: 0 additions & 3 deletions _locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,6 @@
"block_Codec_Alert_h264": {
"message": "You need either H.264 or VP9 enabled for Youtube to play videos."
},
"block_Codec_Alert_VP9": {
"message": "You need either VP9 or H.264 enabled for Youtube to play videos."
},
"blockAll": {
"message": "Off (block or skip)"
},
Expand Down
4 changes: 2 additions & 2 deletions _locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@
"black": {
"message": "Negro"
},
"block_Codec_Alert_VP9": {
"block_Codec_Alert_h264": {
"message": "Necesita activar VP9 o H.264 para que Youtube reproduzca videos."
},
"blockAll": {
Expand Down Expand Up @@ -1109,4 +1109,4 @@
"youtubeLimitsVideoQualityTo1080pForH264Codec": {
"message": "YouTube limita calidad de video a 1080p para el codec h.264"
}
}
}
5 changes: 1 addition & 4 deletions _locales/ja/messages.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"2160p": {
"message": "2160p - 4K"
},
"about": {
"message": "このソフトについて"
},
Expand Down Expand Up @@ -1049,4 +1046,4 @@
"youtubeLimitsVideoQualityTo1080pForH264Codec": {
"message": "YouTubeはH.264コーデックの画質を1080pに制限しています"
}
}
}
8 changes: 1 addition & 7 deletions _locales/pt/messages.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"2160p": {
"message": "2160p - 4K"
},
"about": {
"message": "Sobre"
},
Expand Down Expand Up @@ -161,9 +158,6 @@
"block_Codec_Alert_h264": {
"message": "Você precisa ativar o H.264 ou VP9 para reproduzir vídeos."
},
"block_Codec_Alert_VP9": {
"message": "Você precisa ativar o VP9 ou H.264 para reproduzir vídeos."
},
"blockAll": {
"message": "Bloquear tudo"
},
Expand Down Expand Up @@ -1322,4 +1316,4 @@
"youtubesDark": {
"message": "YouTube escuro"
}
}
}
8 changes: 1 addition & 7 deletions _locales/sw_KE/messages.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
{
"2160p": {
"message": "2160p - 4K"
},
"about": {
"message": "Kuhusu/"
},
Expand Down Expand Up @@ -158,9 +155,6 @@
"block_Codec_Alert_h264": {
"message": "Unahitaji H.264 au VP9 kuwezeshwa kwa YouTube ili kucheza video."
},
"block_Codec_Alert_VP9": {
"message": "Unahitaji VP9 au H.264 kuwezeshwa kwa YouTube ili kucheza video."
},
"blockAll": {
"message": "Imezimwa (zuia au ruka)"
},
Expand Down Expand Up @@ -1298,4 +1292,4 @@
"youtubeLimitsVideoQualityTo1080pForH264Codec": {
"message": "YouTube inaweka kikomo ubora wa video hadi 1080p kwa kodeki ya h.264"
}
}
}
136 changes: 54 additions & 82 deletions menu/skeleton-parts/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -715,6 +715,19 @@ extension.skeleton.main.layers.section.player.on.click = {
}
}
},
mini_player: {
component: 'switch',
text: 'customMiniPlayer'
},
forced_play_video_from_the_beginning: {
component: 'switch',
text: 'forcedPlayVideoFromTheBeginning'
},
player_crop_chapter_titles: {
component: 'switch',
text: 'cropChapterTitles',
value: true
},
player_quality: {
component: 'select',
text: 'quality',
Expand Down Expand Up @@ -758,10 +771,10 @@ extension.skeleton.main.layers.section.player.on.click = {
}],
on: {
render: function () {
// relies on options.text above auto always starting with a number for parseInt to work
// (parseInt) relies on options.text following 'auto' always starting with a number to work
const options = this.childNodes[2].options,
index = this.childNodes[2].selectedIndex;
cutoff = 1080;
index = this.childNodes[2].selectedIndex,
cutoff = 1080;
if (satus.storage.get('player_h264')) {
if (parseInt(options[index].text) > cutoff) {
this.childNodes[1].style = 'color: red!important; font-weight: bold;';
Expand Down Expand Up @@ -802,7 +815,7 @@ extension.skeleton.main.layers.section.player.on.click = {
}
},
/*
qualityWhenRunningOnBattery: {
qualityWhenRunningOnBattery: {
component: 'select',
text: 'qualityWhenRunningOnBattery',
options: function () {
Expand All @@ -822,20 +835,7 @@ extension.skeleton.main.layers.section.player.on.click = {
component: 'switch',
text: 'pauseWhileIUnplugTheCharger'
},
*/
mini_player: {
component: 'switch',
text: 'customMiniPlayer'
},
forced_play_video_from_the_beginning: {
component: 'switch',
text: 'forcedPlayVideoFromTheBeginning'
},
player_crop_chapter_titles: {
component: 'switch',
text: 'cropChapterTitles',
value: true
},
*/
player_codecs: {
component: 'button',
text: 'codecs',
Expand All @@ -850,11 +850,7 @@ extension.skeleton.main.layers.section.player.on.click = {
block_av1: {
component: 'switch',
text: 'blockAv1',
on: {
click: function () {
this.parentElement.skeleton.sanitize();
}
}
value: false
},
block_vp9: {
component: 'switch',
Expand All @@ -869,22 +865,12 @@ extension.skeleton.main.layers.section.player.on.click = {
satus.render({
component: 'modal',
variant: 'confirm',
content: 'block_Codec_Alert_VP9',
ok: function () {
where.flip(true);
where.parentElement.skeleton.sanitize();
},
cancel: function () {
}
content: 'block_Codec_Alert_h264',
ok: function () { where.flip(true); },
cancel: function () {}
}, extension.skeleton.rendered);
} else {
this.flip(true);
this.parentElement.skeleton.sanitize();
}
} else {
this.flip(false);
this.parentElement.skeleton.sanitize();
}
} else this.flip(true);
} else this.flip(false);
}
}
},
Expand All @@ -902,33 +888,13 @@ extension.skeleton.main.layers.section.player.on.click = {
component: 'modal',
variant: 'confirm',
content: 'block_Codec_Alert_h264',
ok: function () {
where.flip(true);
where.parentElement.skeleton.sanitize();
},
cancel: function () {
}
ok: function () { where.flip(true); },
cancel: function () {}
}, extension.skeleton.rendered);
} else {
this.flip(true);
this.parentElement.skeleton.sanitize();
}
} else {
this.flip(false);
this.parentElement.skeleton.sanitize();
}
} else this.flip(true);
} else this.flip(false);
}
}
},
sanitize: function () {
if (satus.storage.get('player_h264')) {
if ((!satus.storage.get('block_vp9') || !satus.storage.get('block_av1') && satus.storage.get('block_h264')) ||
(satus.storage.get('block_vp9') && satus.storage.get('block_av1') && satus.storage.get('block_h264'))) {
satus.storage.set('player_h264', false);
}
} else if (satus.storage.get('block_vp9') && satus.storage.get('block_av1') && !satus.storage.get('block_h264')) {
satus.storage.set('player_h264', true);
}
}
}
}
Expand All @@ -941,18 +907,27 @@ extension.skeleton.main.layers.section.player.on.click = {
},
on: {
render: function () {
var codecs = (satus.storage.get('block_h264') ? '' : 'h.264 ') + (satus.storage.get('block_vp9') ? '' : 'vp9 ') + (satus.storage.get('block_av1') ? '' : 'av1');
if (satus.storage.get('block_vp9') && satus.storage.get('block_av1') && !satus.storage.get('block_h264')) {
satus.storage.set('player_h264', true);
} else {
satus.storage.remove('player_h264');
}

if (codecs.includes('h.264') || codecs.includes('vp9')) {
this.style = '';
this.textContent = codecs;
} else if (codecs) {
const codecs = (satus.storage.get('block_h264') ? '' : 'h.264 ')
+ (satus.storage.get('block_vp9') ? '' : 'vp9 ')
+ (satus.storage.get('block_av1') ? '' : 'av1');

this.style = '';
this.textContent = codecs;
if (codecs === 'av1') {
this.style = 'color: red!important; font-weight: bold;';
this.textContent = codecs;
} else {
} else if (codecs ==='') {
this.style = 'color: red!important; font-weight: bold;';
this.textContent = 'none';
}
document.getElementById('player_quality').dispatchEvent(new CustomEvent('render'));
document.getElementById('player_quality_without_focus').dispatchEvent(new CustomEvent('render'));
//document.getElementById('quality_when_low_battery').dispatchEvent(new CustomEvent('render'));
}
}
}
Expand All @@ -965,15 +940,12 @@ extension.skeleton.main.layers.section.player.on.click = {
custom: true,
on: {
click: function () {
let skeleton = this.parentNode.skeleton;
// refresh player_codecs/optimize_codec_for_hardware_acceleration elements when we change codecs
let refresh = function () {
document.getElementById('player_quality').dispatchEvent(new CustomEvent('render'));
// send signal for #player_codecs to refresh, will in turn redraw #player_quality/#player_quality_without_focus
// when we change player_h264 directly
document.getElementById('player_codecs').dispatchEvent(new CustomEvent('render'));
document.getElementById('optimize_codec_for_hardware_acceleration').dispatchEvent(new CustomEvent('render'));
document.getElementById('player_quality_without_focus').dispatchEvent(new CustomEvent('render'));
//document.getElementById('quality_when_low_battery').dispatchEvent(new CustomEvent('render'));
}
};

if (this.dataset.value === 'false') {
let where = this;
satus.render({
Expand All @@ -985,7 +957,7 @@ extension.skeleton.main.layers.section.player.on.click = {
where.flip(true);
satus.storage.set('block_vp9', true);
satus.storage.set('block_av1', true);
satus.storage.set('block_h264', false);
satus.storage.remove('block_h264');
refresh();
},
cancel: function () {
Expand All @@ -996,15 +968,15 @@ extension.skeleton.main.layers.section.player.on.click = {
// manually turn switch OFF
this.flip(false);
// reset all codecs to unlocked state
satus.storage.set('block_vp9', false);
satus.storage.set('block_av1', false);
satus.storage.set('block_h264', false);
satus.storage.remove('block_vp9');
satus.storage.remove('block_av1');
satus.storage.remove('block_h264');
refresh();
}
}
}
},
optimize_codec_for_hardware_acceleration: {
/*optimize_codec_for_hardware_acceleration: {
component: 'button',
text: 'Optimize Codec for hardware acceleration',
style: {
Expand Down Expand Up @@ -1042,7 +1014,7 @@ extension.skeleton.main.layers.section.player.on.click = {
}
}
}
},
},*/
player_60fps: {
component: 'switch',
text: 'allow60fps',
Expand Down
Loading