From 3d35741ed033a19bff2f96069a77bc3f3a01ad8a Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Tue, 8 Nov 2022 21:52:08 -0800 Subject: [PATCH] video: add HLS fallback --- src/components/PsVideo.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/components/PsVideo.ts b/src/components/PsVideo.ts index 3f89406d..d28b32a7 100644 --- a/src/components/PsVideo.ts +++ b/src/components/PsVideo.ts @@ -95,7 +95,6 @@ class VideoContentSetup { ...hlsSources, { src: e.slide.data.src, - label: "Original", }, ], preload: "metadata", @@ -108,6 +107,18 @@ class VideoContentSetup { }, }); + content.videojs.on("error", function () { + if (this.error().code === 4) { + if (this.src().includes("m3u8")) { + // HLS could not be streamed + console.error("Video.js: HLS stream could not be opened."); + this.src({ + src: e.slide.data.src, + }); + } + } + }); + content.videojs.qualityLevels(); content.videojs.hlsQualitySelector({ displayCurrentQuality: true,