🚧 WIP on dynamic imports

This commit is contained in:
ajnart
2023-02-10 13:20:38 +09:00
parent 793ab4db7a
commit edb13ae716
2 changed files with 8 additions and 6 deletions

View File

@@ -4,8 +4,8 @@
"description": "Embed a video stream or video from a camera or a website", "description": "Embed a video stream or video from a camera or a website",
"settings": { "settings": {
"title": "Settings for video stream widget", "title": "Settings for video stream widget",
"cameraFeedUrl": { "FeedUrl": {
"label": "Camera feed url" "label": "Feed url"
}, },
"autoPlay": { "autoPlay": {
"label": "Auto play" "label": "Auto play"

View File

@@ -1,15 +1,17 @@
import { Center, Group, Stack, Title } from '@mantine/core'; import { Center, Group, Stack, Title } from '@mantine/core';
import { IconDeviceCctv, IconHeartBroken } from '@tabler/icons'; import { IconDeviceCctv, IconHeartBroken } from '@tabler/icons';
import { useTranslation } from 'next-i18next'; import { useTranslation } from 'next-i18next';
import dynamic from 'next/dynamic';
import { defineWidget } from '../helper'; import { defineWidget } from '../helper';
import { IWidget } from '../widgets'; import { IWidget } from '../widgets';
import VideoFeed from './VideoFeed';
const VideoFeed = dynamic(() => import('./VideoFeed'), { ssr: false });
const definition = defineWidget({ const definition = defineWidget({
id: 'video-stream', id: 'video-stream',
icon: IconDeviceCctv, icon: IconDeviceCctv,
options: { options: {
cameraFeedUrl: { FeedUrl: {
type: 'text', type: 'text',
defaultValue: '', defaultValue: '',
}, },
@@ -43,7 +45,7 @@ interface VideoStreamWidgetProps {
function VideoStreamWidget({ widget }: VideoStreamWidgetProps) { function VideoStreamWidget({ widget }: VideoStreamWidgetProps) {
const { t } = useTranslation('modules/video-stream'); const { t } = useTranslation('modules/video-stream');
if (!widget.properties.cameraFeedUrl) { if (!widget.properties.FeedUrl) {
return ( return (
<Center h="100%"> <Center h="100%">
<Stack align="center"> <Stack align="center">
@@ -56,7 +58,7 @@ function VideoStreamWidget({ widget }: VideoStreamWidgetProps) {
return ( return (
<Group position="center" w="100%" h="100%"> <Group position="center" w="100%" h="100%">
<VideoFeed <VideoFeed
source={widget?.properties.cameraFeedUrl} source={widget?.properties.FeedUrl}
muted={widget?.properties.muted} muted={widget?.properties.muted}
autoPlay={widget?.properties.autoPlay} autoPlay={widget?.properties.autoPlay}
controls={widget?.properties.controls} controls={widget?.properties.controls}