startLocalPreview method
Enable the preview image of local camera
If this API is called before enterRoom , the SDK will only enable the camera and wait until enterRoom is called before starting push.
If it is called after enterRoom , the SDK will enable the camera and automatically start pushing the video stream.
When the first camera video frame starts to be rendered, you will receive the TRTCCloudListener.onCameraDidReady callback.
Parameters:
- frontCamera(bool):
- true: front camera; false: rear camera.
- Only works on mobile devices.
- view(int):
- Control that carries the video image.
Note
If you want to preview the camera image and adjust the beauty filter parameters through
BeautyManagerbefore going live, you can:
- Scheme 1: Call startLocalPreview before calling enterRoom.
- Scheme 2: Call startLocalPreview and muteLocalVideo (true) after calling enterRoom.
Implementation
@override
void startLocalPreview(bool frontCamera, int? viewId) async {
TRTCLog(_tag, "startLocalPreview frontCamera: $frontCamera viewId: $viewId");
if (viewId != null && !TRTCCloudVideoView.containsViewId(viewId)) {
TRTCLog(_tag, "startLocalPreview fail, viewId does not exist");
return;
}
TRTCCloudNative.instance.startLocalPreview(frontCamera, _isNativeTexturePlatform ? null : viewId);
if (_isNativeTexturePlatform) {
if (viewId == null) {
await TRTCMethodChannel().unsetLocalTextureRender(TRTCVideoStreamType.big);
} else {
await TRTCMethodChannel().setLocalTextureRender(viewId, TRTCVideoStreamType.big);
}
}
}