TOK BOX 屏幕共享在我的应用程序之外不起作用

TOK BOX Screen sharing is not working outside my app

我为我的应用程序做了屏幕共享(tokbox)。 它在我的应用程序中运行良好。 但是我不能在我的应用程序之外共享屏幕... 有人可以帮忙吗? https://tokbox.com/developer/guides/screen-sharing/android/

我也遇到过同样的问题,并已邮寄给 tokbox 支持。 这是他们的回应:

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.

所以根据他们的说法,您不能在应用程序外共享屏幕。它仅在应用程序处于前台时有效。

更新

在不断询问 tokbox 支持团队后,我得到了以下回复:

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.

根据他们的回复,我找到了 Accelerator Core Android 存储库,其中显示了如何将 Media Projection API 与 tokbox 集成。 更具体地说,这两个文件:ScreenSharingFragment.java and ScreenSharingCapturer.java

使用这两个文件,我现在可以在我的应用程序之外共享屏幕。

注: 面向 Android 9(API 级别 28)或更高级别的应用应使用 Foreground services,否则您的应用将因安全原因崩溃。

根据 Tokbox 的说法,我们无法在应用程序外共享屏幕。

来自视频 API 团队的 Manik。

要在 Android 平台上屏幕共享应用程序之外的内容,您需要使用 Media Projection API. In combination with the Media Projection API, you need to use a Custom Capturer

我们正在开发一个示例应用程序,可让您完成此任务 - 请继续关注!