v2_tx_live_pusher
APIs.dependencies:live_flutter_plugin: latest version number
live_flutter_plugin
, complete the following configuration:import 'package:live_flutter_plugin/v2_tx_live_premier.dart';/// Tencent Cloud license management page (https://console.tencentcloud.com/live/license)setupLicense() {// The license URL of the current applicationvar LICENSEURL = "";// The license key of the current applicationvar LICENSEURLKEY = "";V2TXLivePremier.setLicence(LICENSEURL, LICENSEURLKEY);}
packageName/BundleId
configured in the license must be the same as that of the application; otherwise, stream push will fail.V2TXLivePusher
componentV2TXLivePusher
object and specify V2TXLiveMode
.import 'package:live_flutter_plugin/v2_tx_live_pusher.dart';/// Initialize `V2TXLivePusher`initPusher() {_livePusher = V2TXLivePusher(V2TXLiveMode.v2TXLiveModeRTC);}
import 'package:live_flutter_plugin/widget/v2_tx_live_video_widget.dart';/// The video rendering view widgetWidget renderView() {return V2TXLiveVideoWidget(onViewCreated: (viewId) async {/// Set the video rendering view_livePusher.setRenderViewID(_renderViewId);/// Enable camera preview_livePusher.startCamera(true);},);}
startCamera
to enable camera preview, you can call the startPush API in V2TXLivePusher
to start publishing. You can use TRTC's URL or an RTMP URL for publishing. The former uses UDP. It offers better streaming quality and supports co-anchoring./// Start stream pushstartPush() async {// Generate a stream push address of RTMP/TRTCvar url = "";// Start stream pushawait _livePusher.startPush(url);// Turn the mic onawait _livePusher.startMicrophone();}
/// Stop stream pushstopPush() async {// Turn the camera offawait _livePusher.stopCamera();// Turn the mic offawait _livePusher.stopMicrophone();// Stop stream pushawait _livePusher.stopPush();}
V2TXLIVE_ERROR_INVALID_LICENSE
returned?If the startPush
API returns V2TXLIVE_ERROR_INVALID_LICENSE
, it means your license verification failed. Please check your configuration against Step 2. Configure a license for the SDK.startCamera
before startPush
./// Start stream pushstartPush() async {// Initialize `V2TXLivePusher`_livePusher = V2TXLivePusher(V2TXLiveMode.v2TXLiveModeRTC);// Generate a stream push address of RTMP/TRTCvar url = "";// Start stream pushawait _livePusher.startPush(url);// Turn the mic onawait _livePusher.startMicrophone();}
V2TXLivePusher
to set image definition on the viewer end. The video image watched by the host is the source video without encoding or compression and is not subject to settings. However, viewers can perceive the encoding quality of the video encoder set in setVideoQuality
. For more information, see Setting Video Quality.V2TXLivePusher
to get the TXBeautyManager
instance so as to further set the beauty filter effect.Beauty Filter Style | Description |
TXBeautyStyleSmooth | The smooth style, which features more obvious skin smoothing effects and is suitable for live showrooms. |
TXBeautyStyleNature | The natural style, which retains more facial details and is more natural. |
TXBeautyStylePitu | The Pitu style, which uses the beauty filter algorithm developed by YouTu Lab. Its effect combines the smooth style and the natural style, that is, it retains more skin details than the smooth style and delivers more obvious skin smoothing effects than the natural style. |
Item | Configuration | Description |
Beauty filter strength | Via the setBeautyLevel API in `TXBeautyManager` | Value range: 0-9. `0` means the filter is disabled. The greater the value, the more obvious the effect. |
Skin brightening filter strength | Via the setWhitenessLevel API in `TXBeautyManager` | Value range: 0-9. `0` means the filter is disabled. The greater the value, the more obvious the effect. |
Rosy skin filter strength | Via the setRuddyLevel API in `TXBeautyManager` | Value range: 0-9. `0` means the filter is disabled. The greater the value, the more obvious the effect. |
V2TXLivePusher
offers a set of APIs for device control. You can use getDeviceManager
to get the TXDeviceManager
instance for device management. For detailed directions, see TXDeviceManager API.V2TXLivePusher
to change the camera mirroring mode, so as to change the mirroring effect of the video image seen by viewers. If the host uses the front camera for live streaming, the image will be reversed by the SDK by default.
V2TXLivePusher
pushes video images in portrait mode by default. To push video images in landscape mode, you can modify the parameters in the setVideoQuality API to set the image orientation on viewers' devices.// Video encoding parametersvar param = V2TXLiveVideoEncoderParam();param.videoResolutionMode = isLandscape ? V2TXLiveVideoResolutionMode.v2TXLiveVideoResolutionModeLandscape : V2TXLiveVideoResolutionMode.v2TXLiveVideoResolutionModePortrait;_livePusher.setVideoQuality(param);
V2TXLivePusher
to get a TXAudioEffectManager
instance, which can be used to mix background music and set in-ear monitoring, reverb, and other audio effects. Background music mixing means mixing into the published stream the music played by the host's phone so that the audience can also hear the music.enableVoiceEarMonitor
API in TXAudioEffectManager
to enable in-ear monitoring, which allows hosts to hear their vocals in earphones when they sing.setVoiceReverbType
API in TXAudioEffectManager
to add reverb effects such as karaoke, hall, husky, and metal. The effects are applied to the videos watched by the audience.setVoiceChangerType
API in TXAudioEffectManager
to add voice changing effects such as little girl and middle-aged man to enrich host-audience interaction. The effects are applied to the videos watched by the audience.
Event ID | Code | Description |
V2TXLIVE_ERROR_FAILED | -1 | A common unclassified error occurred. |
V2TXLIVE_ERROR_INVALID_PARAMETER | -2 | An invalid parameter was passed in during API calling. |
V2TXLIVE_ERROR_REFUSED | -3 | The API call was rejected. |
V2TXLIVE_ERROR_NOT_SUPPORTED | -4 | The API cannot be called. |
V2TXLIVE_ERROR_INVALID_LICENSE | -5 | Failed to call the API due to invalid license. |
V2TXLIVE_ERROR_REQUEST_TIMEOUT | -6 | The server request timed out. |
V2TXLIVE_ERROR_SERVER_PROCESS_FAILED | -7 | The server could not handle your request. |
Event ID | Code | Description |
V2TXLIVE_WARNING_NETWORK_BUSY | 1101 | Bad network connection: data upload blocked due to limited upstream bandwidth. |
V2TXLIVE_WARNING_VIDEO_BLOCK | 2105 | Latency during video playback. |
V2TXLIVE_WARNING_CAMERA_START_FAILED | -1301 | Failed to turn the camera on. |
V2TXLIVE_WARNING_CAMERA_OCCUPIED | -1316 | The camera is occupied. Try a different camera. |
V2TXLIVE_WARNING_CAMERA_NO_PERMISSION | -1314 | No access to the camera. This usually occurs on mobile devices and may be because the user denied the access. |
V2TXLIVE_WARNING_MICROPHONE_START_FAILED | -1302 | Failed to turn the mic on. |
V2TXLIVE_WARNING_MICROPHONE_OCCUPIED | -1319 | The mic is occupied. This occurs when, for example, the user is having a call on the mobile device. |
V2TXLIVE_WARNING_MICROPHONE_NO_PERMISSION | -1317 | No access to the mic. This usually occurs on mobile devices and may be because the user denied the access. |
V2TXLIVE_WARNING_SCREEN_CAPTURE_NOT_SUPPORTED | -1309 | The system does not support screen sharing. |
V2TXLIVE_WARNING_SCREEN_CAPTURE_START_FAILED | -1308 | Failed to start screen recording. If this occurs on a mobile device, it may be because the user denied the access. |
V2TXLIVE_WARNING_SCREEN_CAPTURE_INTERRUPTED | -7001 | Screen recording was stopped by the system. |
Was this page helpful?