Improve video playback by integrating HLS.js for adaptive streaming
Replace the iframe embed with a video player utilizing HLS.js for adaptive streaming and update the hls.js dependency to version 1.6.11. Replit-Commit-Author: Agent Replit-Commit-Session-Id: d7424866-83d1-4486-a212-ac12b4c7becf Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/d7424866-83d1-4486-a212-ac12b4c7becf/52uJ2fJ
This commit is contained in:
parent
506bd52dc3
commit
eb29cb0b7e
@ -34,6 +34,7 @@ const formatDate = (date: Date | string): string => {
|
|||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Share2, X, Edit3, Search } from "lucide-react";
|
import { Share2, X, Edit3, Search } from "lucide-react";
|
||||||
|
import Hls from "hls.js";
|
||||||
import { apiRequest } from "@/lib/queryClient";
|
import { apiRequest } from "@/lib/queryClient";
|
||||||
import {
|
import {
|
||||||
FacebookShareButton,
|
FacebookShareButton,
|
||||||
@ -254,16 +255,30 @@ export default function VideoPage() {
|
|||||||
<div className="flex flex-col lg:flex-row gap-6 relative z-10">
|
<div className="flex flex-col lg:flex-row gap-6 relative z-10">
|
||||||
{/* Main video section */}
|
{/* Main video section */}
|
||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
{/* Video player using original Bunny.net iframe */}
|
{/* Video player with HLS.js */}
|
||||||
<div className="relative w-full h-0 pb-[56.25%] bg-black rounded-lg overflow-hidden mb-4">
|
<div className="relative w-full h-0 pb-[56.25%] bg-black rounded-lg overflow-hidden mb-4">
|
||||||
<iframe
|
<video
|
||||||
src={`https://iframe.mediadelivery.net/embed/384105/${currentVideo.id}?autoplay=false&preroll=false`}
|
ref={(video) => {
|
||||||
className="absolute inset-0 w-full h-full"
|
if (video && currentVideo) {
|
||||||
frameBorder="0"
|
const videoSrc = `https://vz-b9208a4c-8c8.b-cdn.net/${currentVideo.id}/playlist.m3u8`;
|
||||||
allowFullScreen
|
|
||||||
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
|
if (Hls.isSupported()) {
|
||||||
onLoad={handleVideoPlay}
|
const hls = new Hls();
|
||||||
title={currentVideo.title}
|
hls.loadSource(videoSrc);
|
||||||
|
hls.attachMedia(video);
|
||||||
|
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||||
|
console.log('HLS video ready');
|
||||||
|
});
|
||||||
|
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
|
||||||
|
video.src = videoSrc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
controls
|
||||||
|
className="absolute inset-0 w-full h-full object-contain"
|
||||||
|
onPlay={handleVideoPlay}
|
||||||
|
preload="metadata"
|
||||||
|
data-testid="video-player"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
8
package-lock.json
generated
8
package-lock.json
generated
@ -67,7 +67,7 @@
|
|||||||
"express-session": "^1.18.2",
|
"express-session": "^1.18.2",
|
||||||
"framer-motion": "^11.13.1",
|
"framer-motion": "^11.13.1",
|
||||||
"google-auth-library": "^10.2.1",
|
"google-auth-library": "^10.2.1",
|
||||||
"hls.js": "^1.6.7",
|
"hls.js": "^1.6.11",
|
||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.4.2",
|
||||||
"lucide-react": "^0.453.0",
|
"lucide-react": "^0.453.0",
|
||||||
"memoizee": "^0.4.17",
|
"memoizee": "^0.4.17",
|
||||||
@ -7441,9 +7441,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hls.js": {
|
"node_modules/hls.js": {
|
||||||
"version": "1.6.7",
|
"version": "1.6.11",
|
||||||
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.6.7.tgz",
|
"resolved": "https://registry.npmjs.org/hls.js/-/hls.js-1.6.11.tgz",
|
||||||
"integrity": "sha512-QW2fnwDGKGc9DwQUGLbmMOz8G48UZK7PVNJPcOUql1b8jubKx4/eMHNP5mGqr6tYlJNDG1g10Lx2U/qPzL6zwQ==",
|
"integrity": "sha512-tdDwOAgPGXohSiNE4oxGr3CI9Hx9lsGLFe6TULUvRk2TfHS+w1tSAJntrvxsHaxvjtr6BXsDZM7NOqJFhU4mmg==",
|
||||||
"license": "Apache-2.0"
|
"license": "Apache-2.0"
|
||||||
},
|
},
|
||||||
"node_modules/html-entities": {
|
"node_modules/html-entities": {
|
||||||
|
|||||||
@ -69,7 +69,7 @@
|
|||||||
"express-session": "^1.18.2",
|
"express-session": "^1.18.2",
|
||||||
"framer-motion": "^11.13.1",
|
"framer-motion": "^11.13.1",
|
||||||
"google-auth-library": "^10.2.1",
|
"google-auth-library": "^10.2.1",
|
||||||
"hls.js": "^1.6.7",
|
"hls.js": "^1.6.11",
|
||||||
"input-otp": "^1.4.2",
|
"input-otp": "^1.4.2",
|
||||||
"lucide-react": "^0.453.0",
|
"lucide-react": "^0.453.0",
|
||||||
"memoizee": "^0.4.17",
|
"memoizee": "^0.4.17",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user