forked from Kieran/snort
NIP-102 demo
This commit is contained in:
parent
939084167a
commit
e07fa411b6
@ -38,6 +38,7 @@ Snort supports the following NIP's:
|
|||||||
- [x] NIP-59: Gift Wrap
|
- [x] NIP-59: Gift Wrap
|
||||||
- [x] NIP-65: Relay List Metadata
|
- [x] NIP-65: Relay List Metadata
|
||||||
- [ ] NIP-78: App specific data
|
- [ ] NIP-78: App specific data
|
||||||
|
- [x] NIP-102: Live Events
|
||||||
|
|
||||||
### Running
|
### Running
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
"debug": "^4.3.4",
|
"debug": "^4.3.4",
|
||||||
"dexie": "^3.2.4",
|
"dexie": "^3.2.4",
|
||||||
"dns-over-http-resolver": "^2.1.1",
|
"dns-over-http-resolver": "^2.1.1",
|
||||||
|
"hls.js": "^1.4.6",
|
||||||
"light-bolt11-decoder": "^2.1.0",
|
"light-bolt11-decoder": "^2.1.0",
|
||||||
"qr-code-styling": "^1.6.0-rc.1",
|
"qr-code-styling": "^1.6.0-rc.1",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
|
21
packages/app/src/Element/LiveEvent.tsx
Normal file
21
packages/app/src/Element/LiveEvent.tsx
Normal 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>
|
||||||
|
);
|
||||||
|
}
|
@ -32,6 +32,7 @@ import { setBookmarked, setPinned } from "Login";
|
|||||||
import { NostrFileElement } from "Element/NostrFileHeader";
|
import { NostrFileElement } from "Element/NostrFileHeader";
|
||||||
import ZapstrEmbed from "Element/ZapstrEmbed";
|
import ZapstrEmbed from "Element/ZapstrEmbed";
|
||||||
import PubkeyList from "Element/PubkeyList";
|
import PubkeyList from "Element/PubkeyList";
|
||||||
|
import { LiveEvent } from "Element/LiveEvent";
|
||||||
|
|
||||||
import messages from "./messages";
|
import messages from "./messages";
|
||||||
|
|
||||||
@ -86,6 +87,9 @@ export default function Note(props: NoteProps) {
|
|||||||
if (ev.kind === EventKind.PubkeyLists) {
|
if (ev.kind === EventKind.PubkeyLists) {
|
||||||
return <PubkeyList ev={ev} className={className} />;
|
return <PubkeyList ev={ev} className={className} />;
|
||||||
}
|
}
|
||||||
|
if (ev.kind === EventKind.LiveEvent) {
|
||||||
|
return <LiveEvent ev={ev} />;
|
||||||
|
}
|
||||||
|
|
||||||
const baseClassName = `note card${className ? ` ${className}` : ""}`;
|
const baseClassName = `note card${className ? ` ${className}` : ""}`;
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
@ -21,6 +21,7 @@ enum EventKind {
|
|||||||
TagLists = 30002, // NIP-51c
|
TagLists = 30002, // NIP-51c
|
||||||
Badge = 30009, // NIP-58
|
Badge = 30009, // NIP-58
|
||||||
ProfileBadges = 30008, // NIP-58
|
ProfileBadges = 30008, // NIP-58
|
||||||
|
LiveEvent = 30311, // NIP-102
|
||||||
ZapstrTrack = 31337,
|
ZapstrTrack = 31337,
|
||||||
ZapRequest = 9734, // NIP 57
|
ZapRequest = 9734, // NIP 57
|
||||||
ZapReceipt = 9735, // NIP 57
|
ZapReceipt = 9735, // NIP 57
|
||||||
|
@ -5769,6 +5769,11 @@ he@1.2.0, he@^1.2.0:
|
|||||||
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
|
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
|
||||||
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
|
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:
|
hoist-non-react-statics@^3.3.0, hoist-non-react-statics@^3.3.2:
|
||||||
version "3.3.2"
|
version "3.3.2"
|
||||||
resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz"
|
resolved "https://registry.npmjs.org/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz"
|
||||||
|
Loading…
Reference in New Issue
Block a user