Show only recent streams

This commit is contained in:
Kieran 2023-06-22 20:47:21 +01:00
parent 64ddb87cc3
commit 15ac0cacb3
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941
2 changed files with 25 additions and 18 deletions

View File

@ -13,22 +13,27 @@ export function LiveVideoPlayer(props: HTMLProps<HTMLVideoElement> & { stream?:
useEffect(() => { useEffect(() => {
if (streamCached && video.current && !video.current.src && Hls.isSupported()) { if (streamCached && video.current && !video.current.src && Hls.isSupported()) {
const hls = new Hls(); try {
hls.loadSource(streamCached); const hls = new Hls();
hls.attachMedia(video.current); hls.loadSource(streamCached);
hls.on(Hls.Events.ERROR, (event, data) => { hls.attachMedia(video.current);
console.debug(event, data); hls.on(Hls.Events.ERROR, (event, data) => {
const errorType = data.type; console.debug(event, data);
if (errorType === Hls.ErrorTypes.NETWORK_ERROR) { const errorType = data.type;
hls.stopLoad(); if (errorType === Hls.ErrorTypes.NETWORK_ERROR) {
hls.detachMedia(); hls.stopLoad();
setStatus(VideoStatus.Offline); hls.detachMedia();
} setStatus(VideoStatus.Offline);
}) }
hls.on(Hls.Events.MANIFEST_PARSED, () => { })
setStatus(VideoStatus.Online); hls.on(Hls.Events.MANIFEST_PARSED, () => {
}) setStatus(VideoStatus.Online);
return () => hls.destroy(); })
return () => hls.destroy();
} catch (e) {
console.error(e);
setStatus(VideoStatus.Offline);
}
} }
}, [video, streamCached]); }, [video, streamCached]);
return ( return (

View File

@ -1,16 +1,18 @@
import "./root.css"; import "./root.css";
import { useMemo } from "react"; import { useMemo } from "react";
import { unixNow } from "@snort/shared";
import { EventKind, ParameterizedReplaceableNoteStore, RequestBuilder } from "@snort/system"; import { EventKind, ParameterizedReplaceableNoteStore, RequestBuilder } from "@snort/system";
import { useRequestBuilder } from "@snort/system-react"; import { useRequestBuilder } from "@snort/system-react";
import { System } from ".."; import { System } from "..";
import { VideoTile } from "../element/video-tile"; import { VideoTile } from "../element/video-tile";
import { findTag } from "utils"; import { findTag } from "utils";
export function RootPage() { export function RootPage() {
const rb = new RequestBuilder("root"); const rb = new RequestBuilder("root");
rb.withFilter() rb.withFilter()
.kinds([30_311 as EventKind]); .kinds([30_311 as EventKind])
.since(unixNow() - 86400);
const feed = useRequestBuilder<ParameterizedReplaceableNoteStore>(System, ParameterizedReplaceableNoteStore, rb); const feed = useRequestBuilder<ParameterizedReplaceableNoteStore>(System, ParameterizedReplaceableNoteStore, rb);
const feedSorted = useMemo(() => { const feedSorted = useMemo(() => {