user3700547
user3700547

Reputation: 23

TOK BOX Screen sharing is not working outside my app

I did screen sharing (tokbox) for my application. It works fine inside my app. But I cannot share screen outside my app... Can anyone plz help? https://tokbox.com/developer/guides/screen-sharing/android/

Upvotes: 0

Views: 1019

Answers (3)

Chinmay Bhardwaj
Chinmay Bhardwaj

Reputation: 111

I had also faced the same issue and had mailed to tokbox support. This was their response:

The way our screen capture code works is that it recursively traverses the view hierarchy and copies those images to a buffer and then send that buffer over on the webrtc data pipe. Hence once the app is pushed to the background, we could not traverse the view hierarchy and copy the image, so screen sharing works until we are in the application (Android or iOS native app). If you want to share the screen view of Opentok app only, it will work but outside the app won't work. It's just to take care of the privacy and security aspects of the mobile app users.

So according to them you cannot share screen outside the application. It will only work when app is in foreground.

Update

After constantly asking the tokbox support team I got the following reply from them:

To screenshare the content outside of your application on Android and iOS can be achieved. For Android, you need to use the Media Projection API together with Vonage/Tokbox Custom Capturer. For iOS, you need to use the iOS ReplayKit together with Vonage/Tokbox Custom Capturer. Basically, the implementation is to get a frame from Media Project API or Replaykit and then pass it via a custom capturer.

Following their response, I found Accelerator Core Android repo which showed how to integrate Media Projection API with tokbox. More specifically these two files: ScreenSharingFragment.java and ScreenSharingCapturer.java

Using these two files I am now able to share screen outside my application.

Note: Apps that target Android 9 (API level 28) or higher should use Foreground services or else your app will crash due to security reasons.

Upvotes: 1

Manik
Manik

Reputation: 1515

Manik here from the Video API team.

To screenshare the contents outside of your application on the Android platform, you need to use the Media Projection API. In combination with the Media Projection API, you need to use a Custom Capturer.

We're working on a sample application that will allow you to accomplish this - please stay tuned!

Upvotes: 0

user3700547
user3700547

Reputation: 23

According to Tokbox, we can't share the screen outside the application.

Upvotes: 0

Related Questions