Add support for enabling / disabling codecs.

This commit is contained in:
FireMasterK 2021-08-27 13:03:55 +05:30
parent e9ee24d4aa
commit c529b003b2
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
3 changed files with 26 additions and 5 deletions

View File

@ -56,11 +56,19 @@ export default {
}, },
preferredVideoCodecs: _this => { preferredVideoCodecs: _this => {
var preferredVideoCodecs = []; var preferredVideoCodecs = [];
const enabledCodecs = _this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(",");
if (_this.$refs.videoEl.canPlayType('video/mp4; codecs="av01.0.08M.08"') !== "") if (
_this.$refs.videoEl.canPlayType('video/mp4; codecs="av01.0.08M.08"') !== "" &&
enabledCodecs.includes("av1")
)
preferredVideoCodecs.push("av01"); preferredVideoCodecs.push("av01");
if (_this.$refs.videoEl.canPlayType('video/webm; codecs="vp9"') !== "") preferredVideoCodecs.push("vp9"); if (_this.$refs.videoEl.canPlayType('video/webm; codecs="vp9"') !== "" && enabledCodecs.includes("vp9"))
if (_this.$refs.videoEl.canPlayType('video/mp4; codecs="avc1.4d401f"') !== "") preferredVideoCodecs.push("vp9");
if (
_this.$refs.videoEl.canPlayType('video/mp4; codecs="avc1.4d401f"') !== "" &&
enabledCodecs.includes("avc")
)
preferredVideoCodecs.push("avc1"); preferredVideoCodecs.push("avc1");
return preferredVideoCodecs; return preferredVideoCodecs;

View File

@ -98,6 +98,14 @@
<select class="uk-select uk-width-auto" v-model="selectedLanguage" @change="onChange($event)"> <select class="uk-select uk-width-auto" v-model="selectedLanguage" @change="onChange($event)">
<option :key="language.code" v-for="language in languages" :value="language.code">{{ language.name }}</option> <option :key="language.code" v-for="language in languages" :value="language.code">{{ language.name }}</option>
</select> </select>
<br />
<b v-t="'actions.enabled_codecs'" />
<br />
<select class="uk-select uk-width-auto" v-model="enabledCodecs" @change="onChange($event)" multiple>
<option value="av1">AV1</option>
<option value="vp9">VP9</option>
<option value="avc">AVC (h.264)</option>
</select>
<h2 v-t="'actions.instances_list'" /> <h2 v-t="'actions.instances_list'" />
<table class="uk-table"> <table class="uk-table">
<thead> <thead>
@ -170,6 +178,7 @@ export default {
{ code: "nb_NO", name: "Norwegian Bokmål" }, { code: "nb_NO", name: "Norwegian Bokmål" },
{ code: "tr", name: "Turkish" }, { code: "tr", name: "Turkish" },
], ],
enabledCodecs: ["av1", "vp9", "avc"],
}; };
}, },
activated() { activated() {
@ -255,6 +264,7 @@ export default {
this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false); this.minimizeDescription = this.getPreferenceBoolean("minimizeDescription", false);
this.watchHistory = this.getPreferenceBoolean("watchHistory", false); this.watchHistory = this.getPreferenceBoolean("watchHistory", false);
this.selectedLanguage = this.getPreferenceString("hl", "en"); this.selectedLanguage = this.getPreferenceString("hl", "en");
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(",");
} }
}, },
methods: { methods: {
@ -265,7 +275,8 @@ export default {
if ( if (
this.getPreferenceString("theme", "dark") !== this.selectedTheme || this.getPreferenceString("theme", "dark") !== this.selectedTheme ||
this.getPreferenceBoolean("watchHistory", false) != this.watchHistory || this.getPreferenceBoolean("watchHistory", false) != this.watchHistory ||
this.getPreferenceString("hl", "en") !== this.selectedLanguage this.getPreferenceString("hl", "en") !== this.selectedLanguage ||
this.getPreferenceString("enabledCodecs", "av1,vp9,avc") !== this.enabledCodecs.join(",")
) )
shouldReload = true; shouldReload = true;
@ -293,6 +304,7 @@ export default {
localStorage.setItem("minimizeDescription", this.minimizeDescription); localStorage.setItem("minimizeDescription", this.minimizeDescription);
localStorage.setItem("watchHistory", this.watchHistory); localStorage.setItem("watchHistory", this.watchHistory);
localStorage.setItem("hl", this.selectedLanguage); localStorage.setItem("hl", this.selectedLanguage);
localStorage.setItem("enabledCodecs", this.enabledCodecs.join(","));
if (shouldReload) window.location.reload(); if (shouldReload) window.location.reload();
} }

View File

@ -43,6 +43,7 @@
"minimize_description": "Minimize Description by default", "minimize_description": "Minimize Description by default",
"store_watch_history": "Store Watch History", "store_watch_history": "Store Watch History",
"language_selection": "Language Selection", "language_selection": "Language Selection",
"instances_list": "Instances List" "instances_list": "Instances List",
"enabled_codecs": "Enabled Codecs (Multiple)"
} }
} }