Tencent tencent_trtc_cloud

English document 日本語の文書

The TRTC SDK for Flutter is based on the SDK for iOS, Android, Windows, and macOS.

Note: Currently, only audio APIs are supported on Windows and macOS. Video calls are supported on Android and iOS.

Note: You cannot run the demo on a simulator. Please debug on a real device.

Demo for video conferencing: GitHub

Demos for one-to-one audio/video call, chat salon, and interactive live streaming: GitHub

If you have any questions, ask us at GitHub Issues or contact us via QQ at 788910197.

Demo quick start

Please see Demo Quick Start (Flutter).

SDK quick integration

Please see SDK Quick Integration (Flutter).

SDK class files

  • trtc_cloud: TRTC main API classes
  • trtc_cloud_video_view: widget that offers TRTCCloudVideoView for video rendering
  • tx_audio_effect_manager: music and audio effect APIs
  • tx_beauty_manager: beauty filter and animated effect management
  • tx_device_manager: device management class
  • trtc_cloud_def: definitions of key TRTC types
  • trtc_cloud_listener: TRTC event callback APIs

Sample call

  1. Initialization
// Create a `TRTCCloud` singleton
trtcCloud = await TRTCCloud.sharedInstance();
// Get the device management module
txDeviceManager = trtcCloud.getDeviceManager();
// Get the beauty filter management object
txBeautyManager = trtcCloud.getBeautyManager();
// Get the audio effect management class
txAudioManager = trtcCloud.getAudioEffectManager();
  1. Room entry/exit
// Enter a room
trtcCloud.enterRoom(
        TRTCParams(
            sdkAppId: sdkAppId, // Application ID
            userId: userId, // User ID
            userSig: userSig, // User signature
            roomId: roomId), // Room ID
        TRTCCloudDef.TRTC_APP_SCENE_VIDEOCALL);
// Leave a room
trtcCloud.exitRoom();
  1. Listener registration
// Register a listener
trtcCloud.registerListener(onRtcListener);
onRtcListener(type, param){
  // Callback for room entry
  if (type == TRTCCloudListener.onEnterRoom) {
    if (param > 0) {
      showToast('Entered the room successfully');
    }
  }
  // Callback for the entry of a remote user
  if (type == TRTCCloudListener.onRemoteUserEnterRoom) {
    // The parameter is the user ID of the remote user.
  }
  // Callback of whether a remote user has playable video in the primary stream (usually used for camera video)
  if (type == TRTCCloudListener.onUserVideoAvailable) {
    //param['userId'] is the user ID of the remote user.
    //param['visible'] indicates whether video is enabled.
  }
}
// Remove a listener
trtcCloud.unRegisterListener(onRtcListener);
  1. Playing local video
// Parameters:
// frontCamera: `true`: front camera; `false`: rear camera
// viewId: view ID generated by `TRTCCloudVideoView`
TRTCCloudVideoView(
    onViewCreated: (viewId) {
      trtcCloud.startLocalPreview(true, viewId);
});
  1. Playing the video of a remote user
// Parameters:
// userId: ID of the remote user
// streamType: type of the remote user’s video stream to play:
//* HD big image: TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG
//* Smooth small image: TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SMALL
// viewId: view ID generated by `TRTCCloudVideoView`
TRTCCloudVideoView(
    onViewCreated: (viewId) {
      trtcCloud.startRemoteView(userId, TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SMALL, viewId);
});
  1. Playing the screen sharing stream of a remote user
/// Parameters:
/// userId: ID of the remote user
/// streamType: type of the remote user’s video stream to play:
///* Substream (screen sharing): TRTCCloudDe.TRTC_VIDEO_STREAM_TYPE_SUB
/// viewId: view ID generated by `TRTCCloudVideoView`
TRTCCloudVideoView(
    onViewCreated: (viewId) {
      trtcCloud.startRemoteView(userId, TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB, viewId);
});

Viewing TRTC logs

TRTC logs are compressed and encrypted by default and are stored in XLOG files.

  • iOS: Documents/log of the application sandbox
  • Android
    • 6.7 or below: /sdcard/log/tencent/liteav
    • 6.8 or above: /sdcard/Android/data/package name/files/log/tencent/liteav/

FAQs

For more questions, please see FAQs > Flutter.

What should I do if I can play video on Android but not on iOS?

Make sure that in info.plist of your project, the value of io.flutter.embedded_views_preview is YES.

What should I do if the error “Manifest merge failed” occurs when compiling my project with Android Studio?

Open /example/android/app/src/main/AndroidManifest.xml.

  1. Add xmlns:tools="http://schemas.android.com/tools" to manifest.

  2. Add tools:replace="android:label" to application.

Illustration

Libraries

trtc_cloud
trtc_cloud_def
trtc_cloud_listener
trtc_cloud_video_view
tx_audio_effect_manager
tx_beauty_manager
tx_device_manager