2022-05-26 06:38:40 +03:00
|
|
|
import React from 'react';
|
|
|
|
import { useRecoilValue } from 'recoil';
|
|
|
|
import {
|
2022-05-26 08:52:27 +03:00
|
|
|
clientConfigStateAtom,
|
2022-05-26 06:38:40 +03:00
|
|
|
ClientConfigStore,
|
|
|
|
isOnlineSelector,
|
|
|
|
serverStatusState,
|
|
|
|
} from '../../../components/stores/ClientConfigStore';
|
2022-09-07 10:00:28 +03:00
|
|
|
import { OfflineBanner } from '../../../components/ui/OfflineBanner/OfflineBanner';
|
|
|
|
import { Statusbar } from '../../../components/ui/Statusbar/Statusbar';
|
|
|
|
import { OwncastPlayer } from '../../../components/video/OwncastPlayer/OwncastPlayer';
|
2022-05-26 08:52:27 +03:00
|
|
|
import { ClientConfig } from '../../../interfaces/client-config.model';
|
2022-05-26 06:38:40 +03:00
|
|
|
import { ServerStatus } from '../../../interfaces/server-status.model';
|
2022-05-17 08:55:22 +03:00
|
|
|
|
|
|
|
export default function VideoEmbed() {
|
2022-05-26 06:38:40 +03:00
|
|
|
const status = useRecoilValue<ServerStatus>(serverStatusState);
|
2022-05-26 08:52:27 +03:00
|
|
|
const clientConfig = useRecoilValue<ClientConfig>(clientConfigStateAtom);
|
|
|
|
|
|
|
|
const { name } = clientConfig;
|
2022-05-26 06:38:40 +03:00
|
|
|
|
2022-10-09 01:05:52 +03:00
|
|
|
const { offlineMessage } = clientConfig;
|
2022-05-26 06:38:40 +03:00
|
|
|
const { viewerCount, lastConnectTime, lastDisconnectTime } = status;
|
|
|
|
const online = useRecoilValue<boolean>(isOnlineSelector);
|
2022-05-17 08:55:22 +03:00
|
|
|
return (
|
2022-05-26 06:38:40 +03:00
|
|
|
<>
|
|
|
|
<ClientConfigStore />
|
|
|
|
<div className="video-embed">
|
|
|
|
{online && <OwncastPlayer source="/hls/stream.m3u8" online={online} />}
|
2022-10-09 01:05:52 +03:00
|
|
|
{!online && (
|
|
|
|
<OfflineBanner
|
|
|
|
streamName={name}
|
|
|
|
customText={offlineMessage}
|
|
|
|
notificationsEnabled={false}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{online && (
|
|
|
|
<Statusbar
|
|
|
|
online={online}
|
|
|
|
lastConnectTime={lastConnectTime}
|
|
|
|
lastDisconnectTime={lastDisconnectTime}
|
|
|
|
viewerCount={viewerCount}
|
|
|
|
/>
|
|
|
|
)}
|
2022-05-26 06:38:40 +03:00
|
|
|
</div>
|
|
|
|
</>
|
2022-05-17 08:55:22 +03:00
|
|
|
);
|
|
|
|
}
|