Skip to content

Commit

Permalink
fix: #172 support react18 (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
JackCompass authored Oct 14, 2022
1 parent 09abbac commit 1b8e0de
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/video-recorder.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,18 @@ export default class VideoRecorder extends Component {
) {
this.tryToUnmuteReplayVideo()
}

if (
this.state.isCameraOn !== prevState.isCameraOn &&
this.state.isCameraOn
) {
// Only if the cameraVideo ref is available
if (window.URL && this.cameraVideo) {
this.cameraVideo.srcObject = this.state.stream
} else {
this.cameraVideo.src = this.state.stream
}
}
}

componentWillUnmount () {
Expand Down Expand Up @@ -334,12 +346,6 @@ export default class VideoRecorder extends Component {
this.props.onCameraOn()
}

if (window.URL) {
this.cameraVideo.srcObject = stream
} else {
this.cameraVideo.src = stream
}

// there is probably a better way
// but this makes sure the start recording button
// gives the stream a couple miliseconds to be ready
Expand Down

0 comments on commit 1b8e0de

Please sign in to comment.