From e4b24043ee7b1aa187f0b90b5d0bce5dc8a8c347 Mon Sep 17 00:00:00 2001 From: FireMasterK <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 21 Jul 2021 16:18:59 +0530 Subject: [PATCH] Fix for browsers without vp9. Closes #293 --- src/components/Player.vue | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/Player.vue b/src/components/Player.vue index 49e829b2..591c9b08 100644 --- a/src/components/Player.vue +++ b/src/components/Player.vue @@ -38,6 +38,17 @@ export default { shouldAutoPlay: _this => { return _this.getPreferenceBoolean("playerAutoPlay", true); }, + preferredVideoCodecs: _this => { + var preferredVideoCodecs = []; + + if (_this.$refs.videoEl.canPlayType('video/mp4; codecs="av01.0.08M.08"') !== "") + preferredVideoCodecs.push("av01"); + if (_this.$refs.videoEl.canPlayType('video/webm; codecs="vp9"') !== "") preferredVideoCodecs.push("vp9"); + if (_this.$refs.videoEl.canPlayType('video/mp4; codecs="avc1.4d401f"') !== "") + preferredVideoCodecs.push("avc1"); + + return preferredVideoCodecs; + }, }, mounted() { if (!this.shaka) this.shakaPromise = shaka.then(shaka => shaka.default).then(shaka => (this.shaka = shaka)); @@ -168,7 +179,7 @@ export default { const disableVideo = this.getPreferenceBoolean("listen", false) && !this.video.livestream; this.player.configure({ - preferredVideoCodecs: ["av01", "vp9", "avc1"], + preferredVideoCodecs: this.preferredVideoCodecs, preferredAudioCodecs: ["opus", "mp4a"], manifest: { disableVideo: disableVideo,