diff --git a/CHANGELOG.md b/CHANGELOG.md index ffa1eee1..38199557 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ This file is manually updated. Please file an issue if something is missing. +## Unreleased + +- **Feature**: "Direct" video playback will now fall back to HLS (transcoding) if playback fails (e.g. due to lack of browser support). + ## v4.13.0 (2023-04-03) - **Feature**: Use GPS location data for timezone calculation. diff --git a/src/components/viewer/PsVideo.ts b/src/components/viewer/PsVideo.ts index ca8161de..d6f0aa4b 100644 --- a/src/components/viewer/PsVideo.ts +++ b/src/components/viewer/PsVideo.ts @@ -193,20 +193,35 @@ class VideoContentSetup { }, })); + // Fallbacks + let directFailed = false; + let hlsFailed = false; + vjs.on("error", () => { if (vjs.src(undefined).includes("m3u8")) { - // HLS could not be streamed - console.error("Video.js: HLS stream could not be opened."); + hlsFailed = true; + console.warn("PsVideo: HLS stream could not be opened."); if (getCurrentUser()?.isAdmin) { showError(t("memories", "Transcoding failed, check Nextcloud logs.")); } - vjs.src({ - src: content.data.src, - type: "video/mp4", - }); - this.updateRotation(content, 0); + if (!directFailed) { + console.warn("PsVideo: Trying direct video stream"); + vjs.src({ + src: content.data.src, + type: "video/mp4", + }); + this.updateRotation(content, 0); + } + } else { + directFailed = true; + console.warn("PsVideo: Direct video stream could not be opened."); + + if (!hlsFailed && !config_noTranscode) { + console.warn("PsVideo: Trying HLS stream"); + vjs.src(this.getHLSsrc(content)); + } } });