diff --git a/src/components/Player.vue b/src/components/Player.vue index 92d458e0..6dbf3ab7 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -1,7 +1,12 @@ @@ -134,7 +139,27 @@ export default { ) this.player.configure("manifest.disableVideo", true); + const quality = Number(localStorage.getItem("quality")); + const qualityConds = quality > 0 && (this.video.audioStreams.length > 0 || this.video.livestream); + if (qualityConds) this.player.configure("abr.enabled", false); + player.load(uri, 0, uri.indexOf("dash+xml") >= 0 ? "application/dash+xml" : "video/mp4").then(() => { + if (qualityConds) { + var leastDiff = Number.MAX_VALUE; + var bestStream = null; + player + .getVariantTracks() + .sort((a, b) => a.bandwidth - b.bandwidth) + .forEach(stream => { + const diff = Math.abs(quality - stream.height); + if (diff < leastDiff) { + leastDiff = diff; + bestStream = stream; + } + }); + player.selectVariantTrack(bestStream); + } + this.video.subtitles.map(subtitle => { player.addTextTrackAsync( subtitle.url, diff --git a/src/components/Preferences.vue b/src/components/Preferences.vue index 08a4642d..cf84749d 100644 --- a/src/components/Preferences.vue +++ b/src/components/Preferences.vue @@ -38,6 +38,21 @@ Audio Only
+
+ Default Quality +
+

Instances List

@@ -85,6 +100,7 @@ export default { skipMusicOffTopic: true, autoPlayVideo: true, audioOnly: false, + defaultQuality: 0, }; }, mounted() { @@ -147,6 +163,7 @@ export default { this.autoPlayVideo = localStorage.getItem("playerAutoPlay") === null || localStorage.getItem("playerAutoPlay") === "true"; this.audioOnly = localStorage.getItem("audioOnly") === "true"; + this.defaultQuality = Number(localStorage.getItem("quality")); } }, methods: { @@ -166,6 +183,7 @@ export default { localStorage.setItem("playerAutoPlay", this.autoPlayVideo); localStorage.setItem("audioOnly", this.audioOnly); + localStorage.setItem("quality", this.defaultQuality); } }, sslScore(url) {