Skip to content

Commit

Permalink
fix: simplify and improve stop replaying flow
Browse files Browse the repository at this point in the history
  • Loading branch information
fbaiodias committed Dec 7, 2018
1 parent e0feb7f commit 10b52d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 2 additions & 5 deletions src/defaults/render-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export default ({
onOpenVideoInput,
onStartRecording,
onStopRecording,
onStopReplaying,
onConfirm
}) => {
const renderContent = () => {
Expand All @@ -52,11 +53,7 @@ export default ({
}

if (isReplayingVideo) {
return shouldUseVideoInput ? (
<Button onClick={onOpenVideoInput}>Record another video</Button>
) : (
<RecordButton onClick={onTurnOnCamera} />
)
return <Button onClick={onStopReplaying}>Record another video</Button>
}

if (isRecording) {
Expand Down
20 changes: 19 additions & 1 deletion src/video-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
})}
</Wrapper>
)
Expand Down

0 comments on commit 10b52d3

Please sign in to comment.