From 10b52d3b674e9367139d7e9891112e99b6067a21 Mon Sep 17 00:00:00 2001 From: Francisco Baio Dias Date: Fri, 7 Dec 2018 12:24:38 +0100 Subject: [PATCH] fix: simplify and improve stop replaying flow --- src/defaults/render-actions.js | 7 ++----- src/video-recorder.js | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/src/defaults/render-actions.js b/src/defaults/render-actions.js index bd31e9a..f1ff5a6 100644 --- a/src/defaults/render-actions.js +++ b/src/defaults/render-actions.js @@ -36,6 +36,7 @@ export default ({ onOpenVideoInput, onStartRecording, onStopRecording, + onStopReplaying, onConfirm }) => { const renderContent = () => { @@ -52,11 +53,7 @@ export default ({ } if (isReplayingVideo) { - return shouldUseVideoInput ? ( - - ) : ( - - ) + return } if (isRecording) { diff --git a/src/video-recorder.js b/src/video-recorder.js index e90d8cd..b7abe54 100644 --- a/src/video-recorder.js +++ b/src/video-recorder.js @@ -129,6 +129,7 @@ export default class VideoRecorder extends Component { this.handleStopRecording = this.handleStopRecording.bind(this) this.handleDataAvailable = this.handleDataAvailable.bind(this) this.handleStop = this.handleStop.bind(this) + this.handleStopReplaying = this.handleStopReplaying.bind(this) this.renderCameraView = this.renderCameraView.bind(this) this.handleVideoSelected = this.handleVideoSelected.bind(this) this.handleOpenVideoInput = this.handleOpenVideoInput.bind(this) @@ -433,6 +434,22 @@ export default class VideoRecorder extends Component { this.videoInput.click() } + handleStopReplaying () { + if (this.props.onStopReplaying) { + this.props.onStopReplaying() + } + + this.setState({ + isReplayingVideo: false + }) + + if (this.state.isInlineRecordingSupported && this.props.isOnInitially) { + this.turnOnCamera() + } else if (this.state.isVideoInputSupported && this.props.isOnInitially) { + this.handleOpenVideoInput() + } + } + renderCameraView () { const { renderDisconnectedView, @@ -549,7 +566,8 @@ export default class VideoRecorder extends Component { onTurnOffCamera: this.turnOffCamera, onOpenVideoInput: this.handleOpenVideoInput, onStartRecording: this.handleStartRecording, - onStopRecording: this.handleStopRecording + onStopRecording: this.handleStopRecording, + onStopReplaying: this.handleStopReplaying })} )