simplify logic

pull/276/head
Mikael Finstad 6 years ago
parent 9b574f7f8c
commit a86808c003

@ -85,7 +85,6 @@ const App = memo(() => {
const [unsupportedFile, setUnsupportedFile] = useState(false); const [unsupportedFile, setUnsupportedFile] = useState(false);
const [html5FriendlyPath, setHtml5FriendlyPath] = useState(); const [html5FriendlyPath, setHtml5FriendlyPath] = useState();
const [working, setWorking] = useState(false); const [working, setWorking] = useState(false);
const [userHtml5ified, setUserHtml5ified] = useState(false);
const [dummyVideoPath, setDummyVideoPath] = useState(false); const [dummyVideoPath, setDummyVideoPath] = useState(false);
const [playing, setPlaying] = useState(false); const [playing, setPlaying] = useState(false);
const [currentTime, setCurrentTime] = useState(); const [currentTime, setCurrentTime] = useState();
@ -123,7 +122,6 @@ const App = memo(() => {
setHtml5FriendlyPath(); setHtml5FriendlyPath();
setDummyVideoPath(); setDummyVideoPath();
setWorking(false); setWorking(false);
setUserHtml5ified(false);
setPlaying(false); setPlaying(false);
setDuration(); setDuration();
setCurrentSeg(0); setCurrentSeg(0);
@ -144,7 +142,7 @@ const App = memo(() => {
if (dummyVideoPath) unlink(dummyVideoPath).catch(console.error); if (dummyVideoPath) unlink(dummyVideoPath).catch(console.error);
}, [dummyVideoPath]); }, [dummyVideoPath]);
const frameRenderEnabled = rotationPreviewRequested || (!userHtml5ified && unsupportedFile); const frameRenderEnabled = rotationPreviewRequested || (!html5FriendlyPath && unsupportedFile);
const setCutTime = useCallback((type, time) => { const setCutTime = useCallback((type, time) => {
const cloned = clone(cutSegments); const cloned = clone(cutSegments);
@ -160,7 +158,7 @@ const App = memo(() => {
setCustomOutDir((filePaths && filePaths.length === 1) ? filePaths[0] : undefined); setCustomOutDir((filePaths && filePaths.length === 1) ? filePaths[0] : undefined);
} }
const fileUri = (html5FriendlyPath || filePath || '').replace(/#/g, '%23'); const fileUri = (dummyVideoPath || html5FriendlyPath || filePath || '').replace(/#/g, '%23');
function getOutputDir() { function getOutputDir() {
if (customOutDir) return customOutDir; if (customOutDir) return customOutDir;
@ -409,7 +407,7 @@ const App = memo(() => {
// TODO use ffmpeg to capture frame // TODO use ffmpeg to capture frame
const capture = useCallback(async () => { const capture = useCallback(async () => {
if (!filePath) return; if (!filePath) return;
if (html5FriendlyPath) { if (html5FriendlyPath || dummyVideoPath) {
errorToast('Capture frame from this video not yet implemented'); errorToast('Capture frame from this video not yet implemented');
return; return;
} }
@ -419,7 +417,7 @@ const App = memo(() => {
console.error(err); console.error(err);
errorToast('Failed to capture frame'); errorToast('Failed to capture frame');
} }
}, [filePath, currentTime, captureFormat, customOutDir, html5FriendlyPath]); }, [filePath, currentTime, captureFormat, customOutDir, html5FriendlyPath, dummyVideoPath]);
const changePlaybackRate = useCallback((dir) => { const changePlaybackRate = useCallback((dir) => {
const video = getVideo(); const video = getVideo();
@ -456,15 +454,13 @@ const App = memo(() => {
setFilePath(fp); setFilePath(fp);
setFileFormat(ff); setFileFormat(ff);
setDetectedFileFormat(ff); setDetectedFileFormat(ff);
setHtml5FriendlyPath(html5FriendlyPathIn);
if (html5FriendlyPathIn) { if (html5FriendlyPathIn) {
setUserHtml5ified(true); setHtml5FriendlyPath(html5FriendlyPathIn);
} else if (!doesPlayerSupportFile(newStreams)) { } else if (!doesPlayerSupportFile(newStreams)) {
setUnsupportedFile(true); setUnsupportedFile(true);
const html5ifiedDummyPathDummy = getOutPath(customOutDir, fp, 'html5ified-dummy.mkv'); const html5ifiedDummyPathDummy = getOutPath(customOutDir, fp, 'html5ified-dummy.mkv');
await ffmpeg.html5ifyDummy(fp, html5ifiedDummyPathDummy); await ffmpeg.html5ifyDummy(fp, html5ifiedDummyPathDummy);
setHtml5FriendlyPath(html5ifiedDummyPathDummy);
setDummyVideoPath(html5ifiedDummyPathDummy); setDummyVideoPath(html5ifiedDummyPathDummy);
} }
} catch (err) { } catch (err) {
@ -722,7 +718,7 @@ const App = memo(() => {
</div> </div>
{/* eslint-enable jsx-a11y/media-has-caption */} {/* eslint-enable jsx-a11y/media-has-caption */}
{html5FriendlyPath && ( {(html5FriendlyPath || dummyVideoPath) && (
<div style={{ position: 'absolute', bottom: 100, right: 0, maxWidth: 300, background: 'rgba(0,0,0,0.2)', color: 'rgba(255,255,255,0.8)', boxShadow: 'rgba(0,0,0,0.2) 0 0 15px 15px' }}> <div style={{ position: 'absolute', bottom: 100, right: 0, maxWidth: 300, background: 'rgba(0,0,0,0.2)', color: 'rgba(255,255,255,0.8)', boxShadow: 'rgba(0,0,0,0.2) 0 0 15px 15px' }}>
This video is not natively supported, so there is no audio in the preview and low FPS. <b>The final cut operation will still be lossless and contain audio!</b> This video is not natively supported, so there is no audio in the preview and low FPS. <b>The final cut operation will still be lossless and contain audio!</b>
</div> </div>

Loading…
Cancel
Save