skrafft / react-native-jitsi-meet

React native wrapper for Jitsi Meet SDK
Apache License 2.0
285 stars 348 forks source link

Screen sharing option is not working in android #392

Open darshitDev opened 2 years ago

darshitDev commented 2 years ago

getting below error while screen sharing

'ERROR creating ScreeSharing stream ', [gum.screensharing_user_canceled: User canceled screen sharing prompt]

hypnocill commented 2 years ago

@darshitDev did you find the reason why the screen sharing is not working?

hypnocill commented 2 years ago

I managed to get it working on Android and on iOS. Here's the topic where I explain the issues first and then my debugging process: https://community.jitsi.org/t/screen-sharing-on-moible-is-not-working/118460/11

Bear in mind that for the Android fix a custom jitsi sdk build is required and patching the react-native-jitsi-meet library

rcidt commented 1 year ago

@hypnocill thanks for the suggestion. I reviewed your comments, but I didn't see what needs to be modified in the JitsiMeetSDK for Android. Could you please point it out?

Shahzad062 commented 1 year ago

@hypnocill kindly tell what should modify

hypnocill commented 1 year ago

@rcidt @Shahzad062 I assume you ask for Android, since for iOS it's pretty clean in the jitsi forum. The concept is as follows: In your app's MainActivity, you need to capture the result of user's decision from the popup when he/she clicks on share screen by adding this:

 @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    JitsiMeetModule.onActivityResult(this, requestCode, resultCode, data);
}

Then you need to define the onActivityResult in JitsiMeetModule which is in RN Jitsi library (I use this fork: https://github.com/vidit-me/react-native-jitsi-meet). For the following changes to the RN jitsi library, you need to either make a patch or a custom build:

public static void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) {
  JitsiMeetActivityDelegate.onActivityResult(activity, requestCode, resultCode, data);
}

This will pass the user's decision for enabling screen sharing from your app to Jitsi.

Also, you need to make sure Jitsi ongoing conference service is started beforehand. I personally did it directly on conference joined event in JitsiMeetViewManager by adding so custom build is needed.

JitsiMeetOngoingConferenceService.launch(this.reactApplicationContext.getCurrentActivity());

In JitsiMeetViewManager -> onBroadcastReceived -> case CONFERENCE_JOINED

And last, in order to be able to call this .launch() method, you need to make it and the 'abort' methods public inside 'JitsiMeetOngoingConferenceService' (This is in JITSI Meet, not in RN jitsi meet, so a custom build is needed)

I hope I don't miss anything since it's been a long time since I did this but this should be it, I think.

Shahzad062 commented 1 year ago

@hypnocill but in my node modules in jitsi meet java folder dont have JitsiMeetActivityDelegate.java file

Shahzad062 commented 1 year ago

i m unable to find JitsiMeetOngoingConferenceService in react native jitsi meet package @hypnocill

hypnocill commented 1 year ago

i m unable to find JitsiMeetOngoingConferenceService in react native jitsi meet package @hypnocill

I edited my comment slightly to clarify which is where (I may not have described it perfectly because I don't have the codebase in front of me now). In short, the description I gave you is within 3 projects:

Your app, RN Jitsi Library (I use this fork: https://github.com/vidit-me/react-native-jitsi-meet), and Jitsi Meet original project. The Jitsi meet original project will need to be built by you in order to make changes to it (refer to their documentation on how to do so).

Shahzad062 commented 1 year ago

@hypnocill i m also using this package https://github.com/vidit-me/react-native-jitsi-meet i have put this code public static void onActivityResult(Activity activity, int requestCode, int resultCode, Intent data) { JitsiMeetActivityDelegate.onActivityResult(activity, requestCode, resultCode, data); } in JitsiMeetModule.java in packge but issue is that JitsiMeetActivityDelegate.onActivityResult using in this code so JitsiMeetActivityDelegate.java file doesnot exist in package java folder second issue i m adding this code JitsiMeetOngoingConferenceService.launch(this.reactApplicationContext.getCurrentActivity()); in JitsiMeetViewManager but in JitsiMeetViewManager and other files dont have this JitsiMeetOngoingConferenceService that why i m getting issue