CaptureScreen.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const { h, Component } = require('preact')
  2. const RecordButton = require('./RecordButton')
  3. const SubmitButton = require('./SubmitButton')
  4. const StopWatch = require('./StopWatch')
  5. const StreamStatus = require('./StreamStatus')
  6. class RecorderScreen extends Component {
  7. componentWillUnmount () {
  8. this.props.onStop()
  9. }
  10. render () {
  11. const { recording, stream: videoStream, recordedVideo } = this.props
  12. const videoProps = {
  13. playsinline: true,
  14. }
  15. // show stream
  16. if (recording || (!recordedVideo && !recording)) {
  17. videoProps.muted = true
  18. videoProps.autoplay = true
  19. videoProps.srcObject = videoStream
  20. }
  21. // show preview
  22. if (recordedVideo && !recording) {
  23. videoProps.muted = false
  24. videoProps.controls = true
  25. videoProps.src = recordedVideo
  26. // reset srcObject in dom. If not resetted, stream sticks in element
  27. if (this.videoElement) {
  28. this.videoElement.srcObject = undefined
  29. }
  30. }
  31. return (
  32. <div className="uppy uppy-ScreenCapture-container">
  33. <div className="uppy-ScreenCapture-videoContainer">
  34. <StreamStatus {...this.props} />
  35. {/* eslint-disable-next-line jsx-a11y/media-has-caption */}
  36. <video ref={videoElement => { this.videoElement = videoElement }} className="uppy-ScreenCapture-video" {...videoProps} />
  37. <StopWatch {...this.props} />
  38. </div>
  39. <div className="uppy-ScreenCapture-buttonContainer">
  40. <RecordButton {...this.props} />
  41. <SubmitButton {...this.props} />
  42. </div>
  43. </div>
  44. )
  45. }
  46. }
  47. module.exports = RecorderScreen