Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding /live to broadcast livestream #40

Merged
merged 7 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added Stream to page
  • Loading branch information
jacobellerbrock committed Oct 26, 2024
commit 58724abb6a5d45312c3b3a251cd7f1281956cba4
1 change: 1 addition & 0 deletions apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"embla-carousel-react": "8.1.7",
"framer-motion": "^11.3.8",
"gsap": "^3.12.5",
"hls.js": "^1.5.17",
"jiti": "^1.21.6",
"lucide-react": "^0.411.0",
"nanoid": "^5.0.7",
Expand Down
55 changes: 41 additions & 14 deletions apps/web/src/app/live/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,43 @@
"use client";
import React, { useEffect, useRef } from 'react';
import Hls from 'hls.js';

export default function LivePage() {
return (
<>
<div style={{backgroundImage: "linear-gradient(to bottom right, #EA580C, #FDE047, #EA580C"}}>
<iframe width="0" height="0"
src="https://www.youtube.com/embed/jfKfPfyJRdk?si=9Gi9Tp5NjCYAhtbU&amp;controls=0"
title="YouTube video player" frameBorder="0"
allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share"
referrerPolicy="strict-origin-when-cross-origin" allowFullScreen
className={"h-dvh w-full border-8 border-transparent"}
/>
</div>

</>
)
}
const streamUrl = "https://82934cf9c8696bd2.mediapackage.us-east-1.amazonaws.com/out/v1/0909ac7915bf450da5267c52f49797cb/index.m3u8"

const videoRef = useRef(null);

useEffect(() => {
// Initialize HLS only if supported
if (Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(streamUrl);
hls.attachMedia(videoRef.current);

hls.on(Hls.Events.MANIFEST_PARSED, () => {
videoRef.current.play();
});

return () => {
hls.destroy();
};
} else if (videoRef.current.canPlayType('application/vnd.apple.mpegurl')) {
// For Safari browsers where HLS is natively supported
videoRef.current.src = streamUrl;
videoRef.current.play();
}
}, [streamUrl]);

return (
<div>
<video
ref={videoRef}
controls
width="1920"
height="1080"
style={{ maxWidth: '100%' }}
/>
</div>
);
};
4 changes: 3 additions & 1 deletion packages/config/hackkit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -858,7 +858,7 @@ const c = {
facebook: "https://facebook.com/rowdyhacks",
twitter: "https://twitter.com/rowdyhacks",
github: "https://github.com/acmutsa",
guide: "https://go.rowdyhacks.org/discord",
guide: "https://guide.rowdyhacks.org",
},
icon: {
sm: "/img/logo/rhbttf.svg",
Expand Down Expand Up @@ -974,6 +974,8 @@ const publicRoutes = [
"/bugreport",
"/faq",
"/live",
"/live/overlay",
"/api/live/announcement"
];

export default c;
Expand Down