Blog

Auto start recording in jitsi

May 1st 2020

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));

Subscribe