forked from Kieran/snort
1
0
Fork 0

NIP-102 demo

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

View File

@ -38,6 +38,7 @@ Snort supports the following NIP's:
- [x] NIP-59: Gift Wrap
- [x] NIP-65: Relay List Metadata
- [ ] NIP-78: App specific data
- [x] NIP-102: Live Events
### Running

View File

@ -16,6 +16,7 @@
"debug": "^4.3.4",
"dexie": "^3.2.4",
"dns-over-http-resolver": "^2.1.1",
"hls.js": "^1.4.6",
"light-bolt11-decoder": "^2.1.0",
"qr-code-styling": "^1.6.0-rc.1",
"react": "^18.2.0",

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

View File

@ -21,6 +21,7 @@ enum EventKind {
TagLists = 30002, // NIP-51c
Badge = 30009, // NIP-58
ProfileBadges = 30008, // NIP-58
LiveEvent = 30311, // NIP-102
ZapstrTrack = 31337,
ZapRequest = 9734, // NIP 57
ZapReceipt = 9735, // NIP 57

View File

@ -5769,6 +5769,11 @@ he@1.2.0, he@^1.2.0:
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
hls.js@^1.4.6:
version "1.4.6"
resolved "https://registry.yarnpkg.com/hls.js/-/hls.js-1.4.6.tgz#928752ef7286259aff8f372d4fa179bf932cac78"
integrity sha512-lGv9QfjfjfuGQfLa/28vDFlYWb9Myq5QuvM9qWp5DyElp8jTGMNodTdeAjOLzaA/fN4XHeG+HhTkRGzntwuDZw==
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
version "3.3.2"
resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz"