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>
);
}

View File

@ -32,6 +32,7 @@ import { setBookmarked, setPinned } from "Login";
import { NostrFileElement } from "Element/NostrFileHeader";
import ZapstrEmbed from "Element/ZapstrEmbed";
import PubkeyList from "Element/PubkeyList";
import { LiveEvent } from "Element/LiveEvent";
import messages from "./messages";
@ -86,6 +87,9 @@ export default function Note(props: NoteProps) {
if (ev.kind === EventKind.PubkeyLists) {
return <PubkeyList ev={ev} className={className} />;
}
if (ev.kind === EventKind.LiveEvent) {
return <LiveEvent ev={ev} />;
}
const baseClassName = `note card${className ? ` ${className}` : ""}`;
const navigate = useNavigate();