Tencent tencent_trtc_cloud
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
- 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();
- 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();
- 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);
- Playing local video
// Parameters:
// frontCamera: `true`: front camera; `false`: rear camera
// viewId: view ID generated by `TRTCCloudVideoView`
TRTCCloudVideoView(
onViewCreated: (viewId) {
trtcCloud.startLocalPreview(true, viewId);
});
- 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);
});
- 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/
- 6.7 or below:
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
.
-
Add
xmlns:tools="http://schemas.android.com/tools"
tomanifest
. -
Add
tools:replace="android:label"
toapplication
.