PromucFlow_constructor/app/client/src/components/designSystems/appsmith/VideoComponent.tsx
satbir121 15f84203c7
Video widget (#684)
* Working version of video player.

* Adding default video url

* Reducing the default widget of video widget

* Fixed tests

* Adding video icon.

* Removing commented code.

* Adding playState, onPause, onStart, onEnd.

* Adding onPlay event.

* Fixing onPlay

* Adding isVisible field.

* Changing video icon.

* Fixing Popover table video.

* Adding an error message for no url.
2020-09-26 18:29:33 +05:30

73 lines
1.5 KiB
TypeScript

import ReactPlayer from "react-player";
import React, { Ref } from "react";
import styled from "styled-components";
import { ENTER_VIDEO_URL } from "constants/messages";
export interface VideoComponentProps {
url?: string;
autoplay?: boolean;
controls?: boolean;
onStart?: () => void;
onPlay?: () => void;
onPause?: () => void;
onEnded?: () => void;
onReady?: () => void;
onProgress?: () => void;
onSeek?: () => void;
onError?: () => void;
player?: Ref<ReactPlayer>;
}
const ErrorContainer = styled.div`
display: flex;
align-items: center;
justify-content: center;
width: 100%;
height: 100%;
`;
const Error = styled.span``;
export default function VideoComponent(props: VideoComponentProps) {
const {
url,
autoplay,
controls,
onStart,
onPlay,
onPause,
onEnded,
onReady,
onProgress,
onSeek,
onError,
player,
} = props;
return (
<>
{url ? (
<ReactPlayer
url={url}
ref={player}
playing={autoplay}
controls={controls || true}
onStart={onStart}
onPlay={onPlay}
onPause={onPause}
onEnded={onEnded}
onReady={onReady}
onProgress={onProgress}
onSeek={onSeek}
onError={onError}
width="100%"
height="100%"
pip={false}
/>
) : (
<ErrorContainer>
<Error>{ENTER_VIDEO_URL}</Error>
</ErrorContainer>
)}
</>
);
}