import * as React from 'react'; import { Renderer, Tester } from './../interfaces'; import globalStyle from './../styles.css' import WithHeader from './wrappers/withHeader'; import WithSeeMore from './wrappers/withSeeMore'; export const renderer: Renderer = ({ story, action, isPaused, config, messageHandler }) => { const [loaded, setLoaded] = React.useState(false); const [muted, setMuted] = React.useState(false); const { width, height, loader, storyStyles } = config; let computedStyles = { ...styles.storyContent, ...(storyStyles || {}) } let vid = React.useRef(null); React.useEffect(() => { if (vid.current) { if (isPaused) { vid.current.pause(); } else { vid.current.play().catch(() => { }); } } }, [isPaused]); const onWaiting = () => { action("pause", true); } const onPlaying = () => { action("play", true); } const videoLoaded = () => { messageHandler('UPDATE_VIDEO_DURATION', { duration: vid.current.duration }); setLoaded(true); vid.current.play().then(() => { action('play'); }).catch(() => { setMuted(true); vid.current.play().finally(() => { action('play'); }) }); } return