import React from 'react'; import { Trans } from '@lingui/macro'; import Grid from '@mui/material/Grid'; import MenuItem from '@mui/material/MenuItem'; import TextField from '@mui/material/TextField'; import Typography from '@mui/material/Typography'; import Checkbox from '../Checkbox'; import Select from '../Select'; function init(settings) { const initSettings = { lhls: false, segmentDuration: 2, listSize: 6, cleanup: true, version: 3, ...settings, }; return initSettings; } export default function Control(props) { const settings = init(props.settings); // Set the defaults React.useEffect(() => { props.onChange(settings, true); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); const handleChange = (what) => (event) => { const value = event.target.value; if (['lhls', 'cleanup'].includes(what)) { settings[what] = !settings[what]; } else { settings[what] = value; } props.onChange(settings, false); }; return ( {/* lhls problems: - naming of the manifests and media files does not work - segmentation of audio and video creates a playback error - hls inputs requires encoding - have to wait for the final integration in hls.js Low latency Mode (LHLS/CMAF)} checked={settings.lhls} onChange={handleChange('lhls')} /> Experimental function. Older browsers and clients may not be supported. */} M3U8 manifest version. Version 3 has the best browser/client compatibility. Segment length (seconds)} value={settings.segmentDuration} onChange={handleChange('segmentDuration')} /> Segment will be cut on the following keyframe after this time has passed. 2 is recommended. List size (segments)} value={settings.listSize} onChange={handleChange('listSize')} /> The maximum number of playlist segments. 0 will contain all the segments. 6 is recommended. Automatic cleanup of all media data} checked={settings.cleanup} onChange={handleChange('cleanup')} /> ); } Control.defaulProps = { settings: {}, onChange: function (settings, automatic) {}, };