NIP-102 demo

This commit is contained in:
2023-06-17 12:53:38 +01:00
parent 939084167a
commit e07fa411b6
6 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,21 @@
import { NostrEvent } from "@snort/system";
import { findTag } from "SnortUtils";
import { useEffect, useRef } from "react";
import Hls from "hls.js";
export function LiveEvent({ ev }: { ev: NostrEvent }) {
const video = useRef<HTMLVideoElement>(null);
useEffect(() => {
const stream = findTag(ev, "streaming");
if (stream && video.current && !video.current.src && Hls.isSupported()) {
const hls = new Hls();
hls.loadSource(stream);
hls.attachMedia(video.current);
}
}, [video, ev]);
return (
<div>
<video ref={video} controls={true} autoPlay={true} muted={true} />
</div>
);
}