startScreenCapture method

Future<void> startScreenCapture(
  1. int streamType,
  2. TRTCVideoEncParam encParams,
  3. {String shareUserId = '',
  4. String shareUserSig = '',
  5. String appGroup = ''}
)

开始桌面屏幕共享,抓取用户屏幕中的内容并将其分享给同房间中的其他用户

参数:

encParams 屏幕共享编码参数。建议您使用上述配置。如果将 encParams 设置为 nil,则将使用 startScreenCapture 调用之前的编码参数设置。

appGroup 此参数仅对 iOS 有效,对 Android 可以忽略。它是主应用程序和广播过程共享的 Application Group Identifier

如果 appGroup 在 iOS 上为空,它将仅成为应用内屏幕共享,并且仅在 iOS 13.0 及以上版本上生效

屏幕共享

不支持:

  • Windows
  • MacOS

Implementation

Future<void> startScreenCapture(int streamType, TRTCVideoEncParam encParams,
    {String shareUserId = '',
    String shareUserSig = '',
    String appGroup = ''}) {
  if (kIsWeb) {
    return _channel.invokeMethod('startScreenCapture', {
      "shareUserId": shareUserId,
      "shareUserSig": shareUserSig,
      "streamType": streamType
    });
  }
  if (!kIsWeb && Platform.isAndroid) {
    return _channel.invokeMethod('startScreenCapture',
        {"encParams": jsonEncode(encParams), "streamType": streamType});
  }
  if (!kIsWeb && Platform.isIOS && appGroup != '') {
    return _channel.invokeMethod('startScreenCaptureByReplaykit', {
      "encParams": jsonEncode(encParams),
      "appGroup": appGroup,
      "streamType": streamType,
    });
  } else if (!kIsWeb && Platform.isIOS && appGroup == '') {
    return _channel.invokeMethod('startScreenCaptureInApp', {
      "encParams": jsonEncode(encParams),
      "streamType": streamType,
    });
  }
  return _channel.invokeMethod('startScreenCapture',
      {"streamType": streamType, "encParams": jsonEncode(encParams)});
}