VideoPage: HLS.js fallback when no Bunny iframe URL

This commit is contained in:
Sebastjan 2026-06-09 00:22:51 +02:00
parent b1d3b77edb
commit ec39596b96

View File

@ -1,3 +1,4 @@
import Hls from "hls.js";
import { useState, useEffect } from "react"; import { useState, useEffect } from "react";
import { useQuery } from "@tanstack/react-query"; import { useQuery } from "@tanstack/react-query";
import { useRoute, useLocation } from "wouter"; import { useRoute, useLocation } from "wouter";
@ -655,6 +656,26 @@ export default function VideoPage() {
onLoad={handleVideoPlay} onLoad={handleVideoPlay}
title={currentVideo.title} title={currentVideo.title}
/> />
) : currentVideo.videoUrl ? (
<video
ref={(el) => {
if (!el || el.dataset.hlsAttached === currentVideo.id) return;
el.dataset.hlsAttached = currentVideo.id;
const src = currentVideo.videoUrl;
if (Hls.isSupported() && src.endsWith('.m3u8')) {
const hls = new Hls();
hls.loadSource(src);
hls.attachMedia(el);
} else {
el.src = src;
}
}}
controls
playsInline
className="absolute inset-0 w-full h-full bg-black"
poster={currentVideo.customThumbnailUrl || currentVideo.thumbnailUrl}
onPlay={handleVideoPlay}
/>
) : ( ) : (
<div className="absolute inset-0 flex items-center justify-center text-white"> <div className="absolute inset-0 flex items-center justify-center text-white">
<p>Video nicht verfügbar</p> <p>Video nicht verfügbar</p>