startScreenCapture method Null safety

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

参数:

屏幕分享使用的线路,可以设置为主路(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG)或者辅路(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB)

encParams 设置屏幕分享时的编码参数,推荐采用上述推荐配置,如果您指定 encParams 为 nil,则使用您调用 startScreenCapture 之前的编码参数设置。

appGroup 该参数仅仅在ios端有效,Android端不需要关注这个参数。该参数是主 App 与 Broadcast 共享的 Application Group Identifier。

在ios下如果appGroup为空的话,将只能变为应用内的屏幕分享,并且只有在iOS 13.0 及以上的有效

在web下需要shareUserId 和 shareUserSig,其他参数无效

屏幕录制

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)});
}