HomeAuthorsContact
WebRTC
Auto start recording in jitsi
Supun Madusanka
May 01, 2020
1 min

Auto start recording

This blog discuss the use case where you need the recording to autostart without manually starting it which is the default behaviour.

Web

class Subject extends Component<Props> {
  componentDidUpdate(prevProps: *, prevState: State) {
    if (prevProps.participantCount === 1 && this.props.participantCount === 2) {
      if (this.props.isModerator && !this.state.isStartRecording) {
        this.setState({ isStartRecording: true }, () => {
          const appData = JSON.stringify({
            file_recording_metadata: {
              share: true
            }
          })

          this.props._conference.startRecording({
            mode: JitsiRecordingConstants.mode.FILE,
            appData
          })
        })
      }
    }
  }
}

function _mapStateToProps(state) {
  const participantCount = getParticipantCount(state)
  const isModerator =
    getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
  return {
    _showParticipantCount: participantCount > 2,
    participantCount,
    _subject: getConferenceName(state),
    _visible: isToolboxVisible(state),
    isModerator,
    _conference: state['features/base/conference'].conference
  }
}

export default connect(_mapStateToProps)(Subject)

Mobile

class LonelyMeetingExperience extends Component<Props> {
  componentDidUpdate(prevProps: *, prevState: State) {
    if (
      prevProps._participantCount === 1 &&
      this.props._participantCount === 2
    ) {
      if (this.props.isModerator && !this.state.isStartRecording) {
        console.log('recording')
        this.setState({ isStartRecording: true }, () => {
          const appData = JSON.stringify({
            file_recording_metadata: {
              share: true
            }
          })

          this.props._conference.startRecording({
            mode: JitsiRecordingConstants.mode.FILE,
            appData
          })
        })
      }
    }
  }
}

function _mapStateToProps(state): $Shape<Props> {
  const { disableInviteFunctions } = state['features/base/config']
  const flag = getFeatureFlag(state, INVITE_ENABLED, true)
  const _participantCount = getParticipantCount(state)
  const isModerator =
    getLocalParticipant(state).role === PARTICIPANT_ROLE.MODERATOR
  return {
    _isInviteFunctionsDiabled: !flag || disableInviteFunctions,
    _isLonelyMeeting: _participantCount === 1,
    isModerator,
    _participantCount,
    _styles: ColorSchemeRegistry.get(state, 'Conference'),
    _conference: state['features/base/conference'].conference
  }
}

export default connect(_mapStateToProps)(translate(LonelyMeetingExperience))


Tags

jitsijibrirecordingauto start

Supun Madusanka

CTO

Expertise

WebRTC
Javascript
React
AWS

Social Media

gitlabgithublinkedin

Related Posts

WebRTC
Jibri Streaming To Custom RMTP Endpoint
August 03, 2020
1 min
© 2021, All Rights Reserved.

Legal Stuff

Privacy NoticeCookie PolicyTerms Of Use

Social Media