diff --git a/examples/DownloadComponent.tsx b/examples/DownloadComponent.tsx deleted file mode 100644 index 550a5c6b..00000000 --- a/examples/DownloadComponent.tsx +++ /dev/null @@ -1,52 +0,0 @@ -import React, { useState, useEffect, useRef } from "react"; -import Recorder from "../src/simularium/StreamRecorder"; -interface VideoRecorderProps { - fileName: string; -} - -//TODO: this is a simple component with stop and start -// we should add a number of features: recording status indicator, progress bar, etc. -// also its odd to record the dead time before the simulation starts -// should the behavior be that we click record, -// and then recording starts and stops when we hit play, pause, or stop? -// We leave this simple and flesh it out in the website, or prototype it here - -const VideoRecorderComponent = ({ fileName }: VideoRecorderProps) => { - const [isRecording, setIsRecording] = useState(false); - const recorderRef = useRef(null); - - useEffect(() => { - // Access the existing canvas element - const canvasEl = document.querySelector("canvas"); - if (canvasEl) { - recorderRef.current = new Recorder(canvasEl, fileName); - } - }, []); - - const startRecording = async () => { - if (recorderRef.current) { - await recorderRef.current.setupStream(); - setIsRecording(true); - } - }; - - const stopRecording = async () => { - if (recorderRef.current) { - await recorderRef.current.onCompletedRecording(); - setIsRecording(false); - } - }; - - return ( -
- - -
- ); -}; - -export default VideoRecorderComponent; diff --git a/examples/VideoRecorder.tsx b/examples/VideoRecorder.tsx index 1e6e344a..976fb7eb 100644 --- a/examples/VideoRecorder.tsx +++ b/examples/VideoRecorder.tsx @@ -21,7 +21,7 @@ const VideoRecorder = ({ trajectoryTitle }: VideoRecorderProps) => { if (canvasEl) { recorderRef.current = new Recorder(canvasEl, trajectoryTitle); } - }, []); + }, [trajectoryTitle]); const startRecording = async () => { if (recorderRef.current) { diff --git a/examples/Viewer.tsx b/examples/Viewer.tsx index e6f694d1..258e43bb 100644 --- a/examples/Viewer.tsx +++ b/examples/Viewer.tsx @@ -637,11 +637,10 @@ class Viewer extends React.Component { } public getTrajectoryTitle = (): string => { - console.log("getTrajectoryTitle", this.state.trajectoryTitle); if (this.state.trajectoryTitle) { return this.state.trajectoryTitle; } else { - return "simulation_recording"; + return "simulation_movie"; } } diff --git a/src/simularium/StreamRecorder.tsx b/src/simularium/StreamRecorder.tsx index 1929b5ff..6ddc7978 100644 --- a/src/simularium/StreamRecorder.tsx +++ b/src/simularium/StreamRecorder.tsx @@ -83,6 +83,9 @@ class Recorder { } else { // if recording and the queue is not full, encode the frame and then close it // encoder is passing chunks to muxer + // don't entirely understand the use of keyFrames + // this is from the docs and will make the resulting video larger but also scrubbable + // can optimize/alter these parameters? this.frameCounter++; const keyFrame = this.frameCounter % 150 === 0; this.encoder.encode(frame, { keyFrame });