Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to start video recording automatically on the Android app without manually starting recording #15067

Open
1 task done
Abhishek-Khanduri opened this issue Aug 29, 2024 · 1 comment

Comments

@Abhishek-Khanduri
Copy link

Abhishek-Khanduri commented Aug 29, 2024

What happened?

I'm trying to automatically start the recording for the meeting as soon as the user joins.

Platform

  • Android mobile app

SDK version

@jitsi/react-native-sdk:^0.3.0

More details?

On my Web I was I am able to achieve this using the following code:

if (!recording) {
        // if current user is not the first participant
        jitsiAPI.stopRecording('file');
}

if (numParticipants === 1 && recording) {
        // if current user is the first participant
        jitsiAPI.startRecording({ mode: 'file' });
}

But on my React Native, I tried using the following to accomplish it but nothing worked out for me
jitsiMeeting.current.startRecording({ mode: 'file' });

This is the complete code

import React, { useCallback, useEffect, useRef } from 'react';
import { BackHandler } from 'react-native';
import { JitsiMeeting } from '@jitsi/react-native-sdk/index';
import config from "src/config";
import { useNavigation } from '@react-navigation/native';

const VideoCallFrame = ({ room, displayName = '', logVideoEvent, callEnded, consent }) => {
  const jitsiMeeting = useRef(null);
  const meetFeatureFlags = {
    'add-people.enabled': false,
    'calendar.enabled': false,
    'call-integration.enabled': false,
    'chat.enabled': false,
    'close-captions.enabled': false,
    'invite.enabled': false,
    'android.screensharing.enabled': false,
    'live-streaming.enabled': false,
    'meeting-name.enabled': false,
    'meeting-password.enabled': true,
    'pip.enabled': true,
    'kick-out.enabled': false,
    'conference-timer.enabled': true,
    'video-share.enabled': false,
    'recording.enabled': true,
    'reactions.enabled': false,
    'raise-hand.enabled': true,
    'tile-view.enabled': true,
    'toolbox.alwaysVisible': true,
    'toolbox.enabled': true,
    'welcomepage.enabled': false,
  };
  const meetConfig = {
    subject: 'Meeting Room',
  };
  const navigation = useNavigation();

  useEffect(() => {
    const backAction = () => {
      jitsiMeeting.current.close();
      callEnded();
      navigation.navigate('mentorshipChat');
    };

    const backHandler = BackHandler.addEventListener(
      "hardwareBackPress",
      backAction
    );

    return () => backHandler.remove();
  }, []);

  const onConferenceLeft = useCallback(() => {
    logVideoEvent(room.room, 'leave', '');
    callEnded();
    console.log("VideoCallFrame onConferenceTerminated");
  }, []);

  const onConferenceWillJoin = useCallback(() => {
    console.log("VideoCallFrame onConferenceWillJoin");
    /* Conference will join event */
  }, []);

  const onConferenceJoined = useCallback(() => {
    console.log(`Debug Room Data: ${JSON.stringify(room)}`);
    logVideoEvent(room.room, 'join', '');
    console.log("VideoCallFrame onConferenceJoined");
    // if (consent?.key === true) {
    jitsiMeeting.current.executeCommand('startRecording', { mode: 'file' });
    // }
  }, []);

  const onReadyToClose = useCallback(() => {
    jitsiMeeting.current.close();
    callEnded();
  }, [navigation]);

  const eventListeners = {
    onReadyToClose,
    onConferenceWillJoin,
    onConferenceLeft,
    onConferenceJoined,
  };

  return (
    <JitsiMeeting
      config={meetConfig}
      eventListeners={eventListeners}
      flags={meetFeatureFlags}
      ref={jitsiMeeting}
      style={{ flex: 1, height: '100%', width: '100%', backgroundColor: 'black' }}
      room={room.room}
      token={room?.token}
      serverURL={config.VIDEO_SERVER_URL}
    />
  );
};

export default VideoCallFrame;

I have a Jibri setup (the Jitsi server is self-hosted using jitsi-docker). Starting and stopping the recording manually works as expected. Any help to do this programmatically would be appreciated!

@Abhishek-Khanduri Abhishek-Khanduri changed the title Not able to record video on the Andorid App without manually starting recording Unable to start video recording automatically on the Android app without manually starting recording Aug 29, 2024
@Abhishek-Khanduri
Copy link
Author

@saghul, Could you please help me with this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant