mirror of
https://github.com/SrIzan10/hctv.git
synced 2026-06-06 00:56:56 +00:00
feat: add preliminary hls reading
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
@@ -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"
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user