feat: add preliminary hls reading

This commit is contained in:
2025-12-13 22:34:29 +01:00
parent 6fcbeaa2a7
commit 8e8c58e195
4 changed files with 24 additions and 7 deletions

View File

@@ -14,11 +14,13 @@ export async function POST(request: NextRequest) {
console.log('Parsed data:', parsed.data);
const { action, protocol, path, password } = parsed.data;
// if (action !== 'publish') return new Response('Action not allowed', { status: 403 });
if (action === 'publish' && protocol !== 'srt') {
const key = await prisma.streamKey.findFirst({
where: {
key: password,
channel: {
name: path,
}
},
include: {
channel: true,

View File

@@ -20,11 +20,17 @@ export default function StreamPlayer() {
return (
<MediaController className="w-full aspect-video">
<HlsVideo
src={`/api/rtmp/hls/${username}.m3u8`}
src={`${process.env.NEXT_PUBLIC_MEDIAMTX_URL}/${username}/index.m3u8`}
slot="media"
crossOrigin="anonymous"
autoplay
config={{
xhrSetup: async (xhr: XMLHttpRequest, url: string) => {
const user = 'skibiditoilet';
const pass = getCookie('auth_session');
const credentials = btoa(`${user}:${pass}`);
xhr.setRequestHeader('Authorization', `Basic ${credentials}`);
},
lowLatencyMode: true,
liveSyncDurationCount: 1,
liveMaxLatencyDurationCount: 2,
@@ -67,3 +73,10 @@ export default function StreamPlayer() {
</MediaController>
);
}
function getCookie(name: string): string | null {
const value = `; ${document.cookie}`;
const parts = value.split(`; ${name}=`);
if (parts.length === 2) return parts.pop()!.split(';').shift() || null;
return null;
}

View File

@@ -1,5 +1,6 @@
import type { Config } from "tailwindcss"
import { withUt } from "uploadthing/tw";
import { uploadthingPlugin } from 'uploadthing/tw'
import * as tan from 'tailwindcss-animate'
const config = {
darkMode: ["class"],
@@ -102,7 +103,7 @@ const config = {
}
}
},
plugins: [require("tailwindcss-animate")],
plugins: [tan, uploadthingPlugin],
} satisfies Config
export default withUt(config)
export default config

View File

@@ -32,8 +32,9 @@
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
".next/types/**/*.ts",
".next/dev/types/**/*.ts"
, "tailwind.config.mts" ],
"exclude": [
"node_modules"
]