@tencent-rtc/mcp 1.2.8 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/resource/doc/chatuikit/faq/common/server.md +44 -0
- package/resource/doc/chatuikit/faq/web_sdk/faq.md +57 -0
- package/resource/doc/livekit/vue/components/co-guest-panel.md +3 -3
- package/resource/doc/livekit/vue/components/live-view.md +4 -4
- package/resource/doc/livekit/vue/{components/live-list.md → live-list-integration.md} +7 -7
- package/resource/doc/livekit/vue/{components/live-player.md → live-player-desk-integration.md} +8 -8
- package/resource/doc/livekit/vue/live-player-h5-integration.md +269 -0
- package/resource/doc/livekit/vue/workflow.md +218 -0
- package/resource/doc/native_live/android/V2TXLiveCode_api_android.md +312 -0
- package/resource/doc/native_live/android/V2TXLiveDef_api_android.md +430 -0
- package/resource/doc/native_live/android/V2TXLivePlayerObserver_api_android.md +679 -0
- package/resource/doc/native_live/android/V2TXLivePlayer_api_android.md +671 -0
- package/resource/doc/native_live/android/V2TXLivePremier_api_android.md +271 -0
- package/resource/doc/native_live/android/V2TXLivePusherObserver_api_android.md +849 -0
- package/resource/doc/native_live/android/V2TXLivePusher_api_android.md +1046 -0
- package/resource/doc/native_live/flutter/V2TXLiveCode_api_flutter.md +460 -0
- package/resource/doc/native_live/flutter/V2TXLiveDef_api_flutter.md +558 -0
- package/resource/doc/native_live/flutter/V2TXLivePlayerObserver_api_flutter.md +865 -0
- package/resource/doc/native_live/flutter/V2TXLivePlayer_api_flutter.md +657 -0
- package/resource/doc/native_live/flutter/V2TXLivePremier_api_flutter.md +437 -0
- package/resource/doc/native_live/flutter/V2TXLivePusherObserver_api_flutter.md +335 -0
- package/resource/doc/native_live/flutter/V2TXLivePusher_api_flutter.md +748 -0
- package/resource/doc/native_live/iOS/V2TXLiveCode_api_iOS.md +327 -0
- package/resource/doc/native_live/iOS/V2TXLiveDef_api_iOS.md +507 -0
- package/resource/doc/native_live/iOS/V2TXLivePlayerObserver_api_iOS.md +507 -0
- package/resource/doc/native_live/iOS/V2TXLivePlayer_api_iOS.md +659 -0
- package/resource/doc/native_live/iOS/V2TXLivePremier_api_iOS.md +284 -0
- package/resource/doc/native_live/iOS/V2TXLivePusherObserver_api_iOS.md +814 -0
- package/resource/doc/native_live/iOS/V2TXLivePusher_api_iOS.md +1000 -0
- package/resource/doc/trtc/C++/ITRTCCloud.md +4119 -0
- package/resource/doc/trtc/C++/ITRTCStatistics.md +325 -0
- package/resource/doc/trtc/C++/ITXAudioEffectManager.md +1289 -0
- package/resource/doc/trtc/C++/ITXDeviceManager.md +1028 -0
- package/resource/doc/trtc/C++/TRTCCloudCallback.md +2650 -0
- package/resource/doc/trtc/C++/TRTCTypeDef.md +3600 -0
- package/resource/doc/trtc/C++/TXLiteAVCode.md +921 -0
- package/resource/doc/trtc/android/TRTCCloud.md +3782 -0
- package/resource/doc/trtc/android/TRTCCloudDef.md +3880 -0
- package/resource/doc/trtc/android/TRTCCloudListener.md +2431 -0
- package/resource/doc/trtc/android/TRTCStatistics.md +295 -0
- package/resource/doc/trtc/android/TXAudioEffectManager.md +1289 -0
- package/resource/doc/trtc/android/TXBeautyManager.md +979 -0
- package/resource/doc/trtc/android/TXDeviceManager.md +440 -0
- package/resource/doc/trtc/android/TXLiteAVCode.md +905 -0
- package/resource/doc/trtc/iOS/TRTCCloud.md +4238 -0
- package/resource/doc/trtc/iOS/TRTCCloudDef.md +3730 -0
- package/resource/doc/trtc/iOS/TRTCCloudDelegate.md +2531 -0
- package/resource/doc/trtc/iOS/TRTCStatistics.md +295 -0
- package/resource/doc/trtc/iOS/TXAudioEffectManager.md +1100 -0
- package/resource/doc/trtc/iOS/TXBeautyManager.md +985 -0
- package/resource/doc/trtc/iOS/TXDeviceManager.md +1024 -0
- package/resource/doc/trtc/iOS/TXLiteAVCode.md +928 -0
- package/tools/definitions/get_faq_def.js +4 -0
- package/tools/definitions/get_faq_def.js.map +1 -1
- package/tools/definitions/get_native_live_api_def.js +23 -0
- package/tools/definitions/get_native_live_api_def.js.map +1 -0
- package/tools/definitions/get_trtc_native_api_def.js +16 -0
- package/tools/definitions/get_trtc_native_api_def.js.map +1 -0
- package/tools/definitions/get_web_live_uikit_component_detail_def.js +13 -8
- package/tools/definitions/get_web_live_uikit_component_detail_def.js.map +1 -1
- package/tools/definitions/get_web_live_uikit_integration_def.js +32 -0
- package/tools/definitions/get_web_live_uikit_integration_def.js.map +1 -0
- package/tools/index.js +8 -0
- package/tools/index.js.map +1 -1
- package/tools/live/get-web-live-uikit-integration.js +52 -0
- package/tools/live/get-web-live-uikit-integration.js.map +1 -0
- package/tools/native_live/get-native-live-api.js +31 -0
- package/tools/native_live/get-native-live-api.js.map +1 -0
- package/tools/trtc/get-trtc-native-api.js +31 -0
- package/tools/trtc/get-trtc-native-api.js.map +1 -0
- package/utils/generate-structured-result.js +34 -0
- package/utils/generate-structured-result.js.map +1 -0
- package/utils/handle-component-name.js +0 -8
- package/utils/handle-component-name.js.map +1 -1
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
- /package/resource/doc/livekit/vue/{components/broadcast.md → live-pusher-integration.md} +0 -0
|
@@ -0,0 +1,671 @@
|
|
|
1
|
+
Tencent Cloud Live Streaming SDK V2TXLivePlayer Playback API Documentation
|
|
2
|
+
|
|
3
|
+
## Feature Overview
|
|
4
|
+
|
|
5
|
+
`V2TXLivePlayer` is the primary interface class for the Tencent Cloud Live Streaming (CSS) player. It handles pulling audio and video data from a specified live stream URL, decoding, and rendering the stream for local playback.
|
|
6
|
+
|
|
7
|
+
**File Path**: `com/tencent/live2/V2TXLivePlayer.java`
|
|
8
|
+
**Platform Support**: Android
|
|
9
|
+
|
|
10
|
+
## Core Features
|
|
11
|
+
|
|
12
|
+
### 🎯 Main Capabilities
|
|
13
|
+
- ✅ **Multi-Protocol Support**: HTTP-FLV, WebRTC, TRTC, HLS, RTMP
|
|
14
|
+
- ✅ **Video Control**: Rotation, fill mode, mirroring
|
|
15
|
+
- ✅ **Playback Control**: Play/stop, pause/resume, volume adjustment
|
|
16
|
+
- ✅ **Cache Optimization**: Automatic cache strategy adjustment
|
|
17
|
+
- ✅ **Seamless Switching**: Seamless multi-resolution stream switching
|
|
18
|
+
- ✅ **Custom Processing**: Audio/video data monitoring and custom rendering
|
|
19
|
+
- ✅ **Advanced Features**: Snapshot, SEI message, Picture-in-Picture, local recording
|
|
20
|
+
|
|
21
|
+
### 🔧 Technical Highlights
|
|
22
|
+
- **Low Latency**: Optimized caching and adaptive network handling
|
|
23
|
+
- **High Compatibility**: Supports multiple video encoding formats and resolutions
|
|
24
|
+
- **Easy Integration**: Simple API design with comprehensive callback support
|
|
25
|
+
- **High Performance**: Hardware Decoding acceleration and efficient rendering pipeline
|
|
26
|
+
|
|
27
|
+
### Player Instance Creation
|
|
28
|
+
```java
|
|
29
|
+
V2TXLivePlayer player = new V2TXLivePlayerImpl(context);
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## API Details
|
|
33
|
+
|
|
34
|
+
### 1. Basic Setup Interfaces
|
|
35
|
+
|
|
36
|
+
#### setObserver() - Set Player Callback
|
|
37
|
+
```java
|
|
38
|
+
public abstract void setObserver(V2TXLivePlayerObserver observer)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
**Parameters**:
|
|
42
|
+
- `observer`: The callback object for the player. Must implement the `V2TXLivePlayerObserver` interface.
|
|
43
|
+
|
|
44
|
+
**When to Call**: Set immediately after initializing the player.
|
|
45
|
+
|
|
46
|
+
**Description**: Assign a callback to monitor player status, playback volume updates, first audio/video frame events, statistics, warnings, and error notifications.
|
|
47
|
+
|
|
48
|
+
**Example**:
|
|
49
|
+
```java
|
|
50
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
51
|
+
// ...
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### setRenderView() - Set Video Rendering View
|
|
56
|
+
```java
|
|
57
|
+
public abstract int setRenderView(TXCloudVideoView view)
|
|
58
|
+
public abstract int setRenderView(TextureView view)
|
|
59
|
+
public abstract int setRenderView(SurfaceView view)
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**Parameters**:
|
|
63
|
+
- `view`: The video rendering view. Supports TXCloudVideoView, TextureView, and SurfaceView (HDR playback requires SurfaceView).
|
|
64
|
+
|
|
65
|
+
**Return Value**: `V2TXLiveCode`
|
|
66
|
+
- `V2TXLIVE_OK`: Success
|
|
67
|
+
|
|
68
|
+
**When to Call**: Set the rendering view before starting playback.
|
|
69
|
+
|
|
70
|
+
**Example**:
|
|
71
|
+
```java
|
|
72
|
+
player.setRenderView(videoView);
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### setRenderRotation() - Set Video Rotation Angle
|
|
76
|
+
```java
|
|
77
|
+
public abstract int setRenderRotation(V2TXLiveRotation rotation)
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
**Parameters**:
|
|
81
|
+
- `rotation`: Rotation angle. See `V2TXLiveDef#V2TXLiveRotation`.
|
|
82
|
+
- `V2TXLiveRotation0` [Default]: 0 degrees (no rotation)
|
|
83
|
+
- `V2TXLiveRotation90`: 90 degrees clockwise
|
|
84
|
+
- `V2TXLiveRotation180`: 180 degrees clockwise
|
|
85
|
+
- `V2TXLiveRotation270`: 270 degrees clockwise
|
|
86
|
+
|
|
87
|
+
**Return Value**: `V2TXLiveCode`
|
|
88
|
+
- `V2TXLIVE_OK`: Success
|
|
89
|
+
|
|
90
|
+
**When to Call**: No restrictions.
|
|
91
|
+
|
|
92
|
+
**Example**:
|
|
93
|
+
```java
|
|
94
|
+
// Set video rotation to 0 degrees
|
|
95
|
+
player.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation0);
|
|
96
|
+
// Set video rotation to 90 degrees
|
|
97
|
+
player.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation90);
|
|
98
|
+
// Set video rotation to 180 degrees
|
|
99
|
+
player.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation180);
|
|
100
|
+
// Set video rotation to 270 degrees
|
|
101
|
+
player.setRenderRotation(V2TXLiveDef.V2TXLiveRotation.V2TXLiveRotation270);
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### setRenderFillMode() - Set Video Fill Mode
|
|
105
|
+
```java
|
|
106
|
+
public abstract int setRenderFillMode(V2TXLiveFillMode mode)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
**Parameters**:
|
|
110
|
+
- `mode`: Fill mode. See `V2TXLiveDef#V2TXLiveFillMode`.
|
|
111
|
+
- `V2TXLiveFillModeFill` [Default]: Fills the screen, no black bars. If the aspect ratio differs, part of the image may be cropped.
|
|
112
|
+
- `V2TXLiveFillModeFit`: Fits the image to the screen, preserves the entire image, but may show black bars if aspect ratios differ.
|
|
113
|
+
- `V2TXLiveFillModeScaleFill`: Stretches the image to fill the screen. Width and height may not scale proportionally.
|
|
114
|
+
|
|
115
|
+
**Return Value**: `V2TXLiveCode`
|
|
116
|
+
- `V2TXLIVE_OK`: Success
|
|
117
|
+
|
|
118
|
+
**When to Call**: No restrictions.
|
|
119
|
+
|
|
120
|
+
**Example**:
|
|
121
|
+
```java
|
|
122
|
+
// Fill image to screen
|
|
123
|
+
player.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFill);
|
|
124
|
+
// Fit image to screen
|
|
125
|
+
player.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeFit);
|
|
126
|
+
// Stretch image to fill
|
|
127
|
+
player.setRenderFillMode(V2TXLiveDef.V2TXLiveFillMode.V2TXLiveFillModeScaleFill);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### setRenderMirrorMode() - Set Video Mirroring Mode
|
|
131
|
+
```java
|
|
132
|
+
public abstract int setRenderMirrorMode(boolean enable)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Parameters**:
|
|
136
|
+
- `enable`: Enable mirroring mode during playback. [Default]: false
|
|
137
|
+
|
|
138
|
+
**Description**: When enabled, the video is flipped horizontally. You can toggle this effect at any time.
|
|
139
|
+
|
|
140
|
+
**Return Value**: `V2TXLiveCode`
|
|
141
|
+
- `V2TXLIVE_OK`: Success
|
|
142
|
+
|
|
143
|
+
**When to Call**: No restrictions.
|
|
144
|
+
|
|
145
|
+
**Example**:
|
|
146
|
+
```java
|
|
147
|
+
// Enable mirroring mode
|
|
148
|
+
player.setRenderMirrorMode(true);
|
|
149
|
+
// Disable mirroring mode
|
|
150
|
+
player.setRenderMirrorMode(false);
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### 2. Playback Control Interfaces
|
|
154
|
+
|
|
155
|
+
### startLivePlay() - Start Audio/Video Playback
|
|
156
|
+
```java
|
|
157
|
+
public abstract int startLivePlay(String url)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
**Parameters**:
|
|
161
|
+
- `url`: Stream playback URL. Supports HTTP-FLV, WebRTC, TRTC, HLS, RTMP.
|
|
162
|
+
|
|
163
|
+
**Return Value**: `V2TXLiveCode`
|
|
164
|
+
- `V2TXLIVE_OK`: Playback started successfully
|
|
165
|
+
- `V2TXLIVE_ERROR_INVALID_PARAMETER`: Invalid URL
|
|
166
|
+
- `V2TXLIVE_ERROR_REFUSED`: RTC does not support pushing and pulling the same StreamId on the same device simultaneously
|
|
167
|
+
- `V2TXLIVE_ERROR_INVALID_LICENSE`: Invalid Licence, playback failed
|
|
168
|
+
|
|
169
|
+
**Important Note**:
|
|
170
|
+
- Starting from version 10.7, you must set the Licence using `V2TXLivePremier#setLicence` before playback. Otherwise, playback will fail (black screen). Only needs to be set once globally.
|
|
171
|
+
- Supports live streaming Licence, short video Licence, and video playback Licence.
|
|
172
|
+
|
|
173
|
+
**When to Call**: No restrictions.
|
|
174
|
+
|
|
175
|
+
**Example**:
|
|
176
|
+
```java
|
|
177
|
+
int result = player.startLivePlayer("http://example.com/live/stream_1080p.flv");
|
|
178
|
+
if (result == V2TXLiveCode.V2TXLIVE_OK) {
|
|
179
|
+
Log.i(TAG, "Playback started successfully");
|
|
180
|
+
} else if (result == V2TXLiveCode.V2TXLIVE_ERROR_INVALID_PARAMETER) {
|
|
181
|
+
Log.w(TAG, "Invalid playback address");
|
|
182
|
+
} else if (result == V2TXLiveCode.V2TXLIVE_ERROR_REFUSED) {
|
|
183
|
+
Log.w(TAG, "Call refused");
|
|
184
|
+
} else if (result == V2TXLiveCode.V2TXLIVE_ERROR_INVALID_LICENSE) {
|
|
185
|
+
Log.w(TAG, "Invalid Licence, please check your Licence");
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### stopPlay() - Stop Audio/Video Playback
|
|
190
|
+
```java
|
|
191
|
+
public abstract int stopPlay()
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
**Return Value**: `V2TXLiveCode`
|
|
195
|
+
- `V2TXLIVE_OK`: Success
|
|
196
|
+
|
|
197
|
+
**When to Call**: After playback has started.
|
|
198
|
+
|
|
199
|
+
**Example**:
|
|
200
|
+
```java
|
|
201
|
+
player.stopPlay();
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### isPlaying() - Check Playback Status
|
|
205
|
+
```java
|
|
206
|
+
public abstract int isPlaying()
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
**Return Value**:
|
|
210
|
+
- `1`: Currently playing
|
|
211
|
+
- `0`: Playback stopped
|
|
212
|
+
|
|
213
|
+
**When to Call**: No restrictions.
|
|
214
|
+
|
|
215
|
+
**Example**:
|
|
216
|
+
```java
|
|
217
|
+
int isPlaying = player.isPlaying();
|
|
218
|
+
if (isPlaying == 1) {
|
|
219
|
+
Log.i(TAG, "Currently playing");
|
|
220
|
+
} else {
|
|
221
|
+
Log.i(TAG, "Playback stopped");
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### 3. Audio/Video Control Interfaces
|
|
226
|
+
|
|
227
|
+
### pauseAudio() - Pause Audio Playback
|
|
228
|
+
```java
|
|
229
|
+
public abstract int pauseAudio()
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
**Return Value**: `V2TXLiveCode`
|
|
233
|
+
- `V2TXLIVE_OK`: Success
|
|
234
|
+
|
|
235
|
+
**When to Call**: No restrictions. If called before playback starts, only video will play (no audio).
|
|
236
|
+
|
|
237
|
+
**Example**:
|
|
238
|
+
```java
|
|
239
|
+
player.pauseAudio();
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### resumeAudio() - Resume Audio Playback
|
|
243
|
+
```java
|
|
244
|
+
public abstract int resumeAudio()
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Return Value**: `V2TXLiveCode`
|
|
248
|
+
- `V2TXLIVE_OK`: Success
|
|
249
|
+
|
|
250
|
+
**When to Call**: No restrictions.
|
|
251
|
+
|
|
252
|
+
**Example**:
|
|
253
|
+
```java
|
|
254
|
+
player.resumeAudio();
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
### pauseVideo() - Pause Video Playback
|
|
258
|
+
```java
|
|
259
|
+
public abstract int pauseVideo()
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
**Return Value**: `V2TXLiveCode`
|
|
263
|
+
- `V2TXLIVE_OK`: Success
|
|
264
|
+
|
|
265
|
+
**When to Call**: No restrictions. If called before playback starts, only audio will play (no video).
|
|
266
|
+
|
|
267
|
+
**Example**:
|
|
268
|
+
```java
|
|
269
|
+
player.pauseVideo();
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### resumeVideo() - Resume Video Playback
|
|
273
|
+
```java
|
|
274
|
+
public abstract int resumeVideo()
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
**Return Value**: `V2TXLiveCode`
|
|
278
|
+
- `V2TXLIVE_OK`: Success
|
|
279
|
+
|
|
280
|
+
**When to Call**: No restrictions.
|
|
281
|
+
|
|
282
|
+
**Example**:
|
|
283
|
+
```java
|
|
284
|
+
player.resumeVideo();
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### setPlayoutVolume() - Adjust Playback Volume
|
|
288
|
+
```java
|
|
289
|
+
public abstract int setPlayoutVolume(int volume)
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
**Parameters**:
|
|
293
|
+
- `volume`: Volume level, range 0–100. [Default]: 100
|
|
294
|
+
|
|
295
|
+
**Return Value**: `V2TXLiveCode`
|
|
296
|
+
- `V2TXLIVE_OK`: Success
|
|
297
|
+
|
|
298
|
+
**When to Call**: No restrictions.
|
|
299
|
+
|
|
300
|
+
**Example**:
|
|
301
|
+
```java
|
|
302
|
+
player.setPlayoutVolume(50);
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
### 4. Advanced Feature Interfaces
|
|
306
|
+
|
|
307
|
+
### setCacheParams() - Configure Cache Time Range
|
|
308
|
+
```java
|
|
309
|
+
public abstract int setCacheParams(float minTime, float maxTime)
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
**Parameters**:
|
|
313
|
+
- `minTime`: Minimum cache time for automatic adjustment. Must be > 0. [Default]: 1
|
|
314
|
+
- `maxTime`: Maximum cache time for automatic adjustment. Must be > 0. [Default]: 5
|
|
315
|
+
|
|
316
|
+
**Return Value**: `V2TXLiveCode`
|
|
317
|
+
- `V2TXLIVE_OK`: Success
|
|
318
|
+
- `V2TXLIVE_ERROR_INVALID_PARAMETER`: minTime and maxTime must be greater than 0
|
|
319
|
+
|
|
320
|
+
**Optimization Tips**:
|
|
321
|
+
- Stable network: Use a smaller cache (1–3 seconds)
|
|
322
|
+
- Unstable network: Use a larger cache (3–5 seconds)
|
|
323
|
+
- If unsure, use default values
|
|
324
|
+
|
|
325
|
+
**When to Call**: No restrictions.
|
|
326
|
+
|
|
327
|
+
**Example**:
|
|
328
|
+
```java
|
|
329
|
+
player.setCacheParams(1, 5);
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
### switchStream() - Switch Stream Resolution Seamlessly (FLV, LEB)
|
|
333
|
+
```java
|
|
334
|
+
public abstract int switchStream(String newUrl)
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
**Parameters**:
|
|
338
|
+
- `newUrl`: URL for the new stream resolution
|
|
339
|
+
|
|
340
|
+
**Return Value**: `V2TXLiveCode`
|
|
341
|
+
- `V2TXLIVE_OK`: Success
|
|
342
|
+
|
|
343
|
+
**When to Call**: After playback has started.
|
|
344
|
+
|
|
345
|
+
**Example**:
|
|
346
|
+
```java
|
|
347
|
+
player.startLivePlayer("http://example.com/live/stream_1080p.flv");
|
|
348
|
+
|
|
349
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
350
|
+
@Override
|
|
351
|
+
public void onStreamSwitched(V2TXLivePlayer player, String url, int code) {
|
|
352
|
+
if (code == 0) {
|
|
353
|
+
Log.i(TAG, "Switch successful");
|
|
354
|
+
} else if (code == -1) {
|
|
355
|
+
Log.i(TAG, "Switch timeout");
|
|
356
|
+
} else if (code == -2) {
|
|
357
|
+
Log.i(TAG, "Switch failed, server error");
|
|
358
|
+
} else if (code == -3) {
|
|
359
|
+
Log.i(TAG, "Switch failed, client error");
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
});
|
|
363
|
+
player.switchStream("http://example.com/live/stream_720p.flv");
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
### getStreamList() - Retrieve Stream Information (HLS Supported)
|
|
367
|
+
```java
|
|
368
|
+
public abstract ArrayList<V2TXLiveDef.V2TXLiveStreamInfo> getStreamList()
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
**Return Value**: Array of stream information, including available resolutions
|
|
372
|
+
|
|
373
|
+
**When to Call**: After playback has started.
|
|
374
|
+
|
|
375
|
+
**Example**:
|
|
376
|
+
```java
|
|
377
|
+
player.startLivePlayer("http://example.com/live/stream_1080p.m3u8");
|
|
378
|
+
|
|
379
|
+
ArrayList<V2TXLiveStreamInfo> streamList = player.getStreamList();
|
|
380
|
+
```
|
|
381
|
+
|
|
382
|
+
### enableVolumeEvaluation() - Enable Playback Volume Level Callback
|
|
383
|
+
```java
|
|
384
|
+
public abstract int enableVolumeEvaluation(int intervalMs)
|
|
385
|
+
```
|
|
386
|
+
|
|
387
|
+
**Parameters**:
|
|
388
|
+
- `intervalMs`: Callback interval for `onPlayoutVolumeUpdate` (ms). Minimum: 100ms. If ≤ 0, disables callback. Recommended: 300ms. [Default]: 0 (disabled)
|
|
389
|
+
|
|
390
|
+
**Description**: When enabled, the SDK reports playback volume levels via the `V2TXLivePlayerObserver` callback.
|
|
391
|
+
|
|
392
|
+
**Return Value**: `V2TXLiveCode`
|
|
393
|
+
- `V2TXLIVE_OK`: Success
|
|
394
|
+
|
|
395
|
+
**When to Call**: No restrictions.
|
|
396
|
+
|
|
397
|
+
**Example**:
|
|
398
|
+
```java
|
|
399
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
400
|
+
@Override
|
|
401
|
+
public void onPlayoutVolumeUpdate(V2TXLivePlayer player, int volume) {
|
|
402
|
+
// Audio playback volume callback
|
|
403
|
+
Log.i(TAG, "Audio playback volume, volume: " + volume);
|
|
404
|
+
}
|
|
405
|
+
});
|
|
406
|
+
player.enableVolumeEvaluation(300);
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
### snapshot() - Capture Video Frame
|
|
410
|
+
```java
|
|
411
|
+
public abstract int snapshot()
|
|
412
|
+
```
|
|
413
|
+
|
|
414
|
+
**Return Value**: `V2TXLiveCode`
|
|
415
|
+
- `V2TXLIVE_OK`: Success
|
|
416
|
+
- `V2TXLIVE_ERROR_REFUSED`: Snapshot not allowed when player is stopped
|
|
417
|
+
|
|
418
|
+
**When to Call**: After playback has started.
|
|
419
|
+
|
|
420
|
+
**Example**:
|
|
421
|
+
```java
|
|
422
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
423
|
+
@Override
|
|
424
|
+
public void onSnapshotComplete(V2TXLivePlayer player, Bitmap image) {
|
|
425
|
+
// Handle snapshot result
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
player.snapshot();
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
### enableObserveVideoFrame() - Enable Custom Video Rendering
|
|
432
|
+
```java
|
|
433
|
+
public abstract int enableObserveVideoFrame(boolean enable, V2TXLivePixelFormat pixelFormat, V2TXLiveBufferType bufferType)
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
**Parameters**:
|
|
437
|
+
- `enable`: Enable custom rendering. [Default]: false
|
|
438
|
+
- `pixelFormat`: Pixel format for custom rendering callback. See `V2TXLiveDef#V2TXLivePixelFormat`.
|
|
439
|
+
- `bufferType`: Video data format for custom rendering callback. See `V2TXLiveDef#V2TXLiveBufferType`.
|
|
440
|
+
|
|
441
|
+
**Description**:
|
|
442
|
+
- When enabled, the SDK stops rendering video frames internally. You can access video frames via `V2TXLivePlayerObserver` for custom rendering.
|
|
443
|
+
- Supported combinations:
|
|
444
|
+
- V2TXLiveDef.V2TXLivePixelFormat.V2TXLivePixelFormatTexture2D + V2TXLiveDef.V2TXLiveBufferType.V2TXLiveBufferTypeTexture (recommended)
|
|
445
|
+
- V2TXLiveDef.V2TXLivePixelFormat.V2TXLivePixelFormatI420 + V2TXLiveDef.V2TXLiveBufferType.V2TXLiveBufferTypeByteArray
|
|
446
|
+
- V2TXLiveDef.V2TXLivePixelFormat.V2TXLivePixelFormatI420 + V2TXLiveDef.V2TXLiveBufferType.V2TXLiveBufferTypeByteBuffer
|
|
447
|
+
|
|
448
|
+
**Return Value**: `V2TXLiveCode`
|
|
449
|
+
- `V2TXLIVE_OK`: Success
|
|
450
|
+
- `V2TXLIVE_ERROR_NOT_SUPPORTED`: Unsupported pixel or data format
|
|
451
|
+
|
|
452
|
+
**When to Call**: Before starting playback.
|
|
453
|
+
|
|
454
|
+
**Example**:
|
|
455
|
+
```java
|
|
456
|
+
// Enable custom rendering
|
|
457
|
+
player.enableObserveVideoFrame(true, V2TXLiveDef.V2TXLivePixelFormat.V2TXLivePixelFormatTexture2D, V2TXLiveDef.V2TXLiveBufferType.V2TXLiveBufferTypeTexture);
|
|
458
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
459
|
+
@Override
|
|
460
|
+
public void onRenderVideoFrame(V2TXLivePlayer player, V2TXLiveVideoFrame videoFrame) {
|
|
461
|
+
// Custom rendering logic
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
```
|
|
465
|
+
|
|
466
|
+
### enableObserveAudioFrame() - Enable Audio Data Callback
|
|
467
|
+
```java
|
|
468
|
+
public abstract int enableObserveAudioFrame(boolean enable)
|
|
469
|
+
```
|
|
470
|
+
|
|
471
|
+
**Parameters**:
|
|
472
|
+
- `enable`: Enable audio data callback. [Default]: false
|
|
473
|
+
|
|
474
|
+
**Description**: When enabled, you can access audio data via `V2TXLivePlayerObserver` for custom processing.
|
|
475
|
+
|
|
476
|
+
**Return Value**: `V2TXLiveCode`
|
|
477
|
+
- `V2TXLIVE_OK`: Success
|
|
478
|
+
|
|
479
|
+
**When to Call**: Before starting playback.
|
|
480
|
+
|
|
481
|
+
**Example**:
|
|
482
|
+
```java
|
|
483
|
+
// Enable audio data monitoring
|
|
484
|
+
player.enableObserveAudioFrame(true);
|
|
485
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
486
|
+
@Override
|
|
487
|
+
public void onPlayoutAudioFrame(V2TXLivePlayer player, V2TXLiveAudioFrame audioFrame) {
|
|
488
|
+
// Handle audio frame
|
|
489
|
+
}
|
|
490
|
+
});
|
|
491
|
+
```
|
|
492
|
+
|
|
493
|
+
### enableReceiveSeiMessage() - Enable SEI Message Reception
|
|
494
|
+
```java
|
|
495
|
+
public abstract int enableReceiveSeiMessage(boolean enable, int payloadType)
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
**Parameters**:
|
|
499
|
+
- `enable`: true to enable, false to disable SEI message reception. [Default]: false
|
|
500
|
+
- `payloadType`: Payload type for SEI messages. Supports 5, 242, 243. Must match sender's payloadType.
|
|
501
|
+
|
|
502
|
+
**Return Value**: `V2TXLiveCode`
|
|
503
|
+
- `V2TXLIVE_OK`: Success
|
|
504
|
+
|
|
505
|
+
**When to Call**: Before starting playback.
|
|
506
|
+
|
|
507
|
+
**Example**:
|
|
508
|
+
```java
|
|
509
|
+
player.enableReceiveSeiMessage(true, 5);
|
|
510
|
+
player.enableReceiveSeiMessage(true, 242);
|
|
511
|
+
player.enableReceiveSeiMessage(true, 243);
|
|
512
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
513
|
+
@Override
|
|
514
|
+
public void onReceiveSeiMessage(V2TXLivePlayer player, int payloadType, byte[] data) {
|
|
515
|
+
// Handle SEI message
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
### startLocalRecording() - Start Local Recording
|
|
521
|
+
```java
|
|
522
|
+
public abstract int startLocalRecording(V2TXLiveLocalRecordingParams params)
|
|
523
|
+
```
|
|
524
|
+
|
|
525
|
+
**Parameters**:
|
|
526
|
+
- `params`: See `V2TXLiveDef.java` for details on `V2TXLiveLocalRecordingParams`
|
|
527
|
+
|
|
528
|
+
**Important Notes**:
|
|
529
|
+
- Recording can only start after stream pulling is enabled. Starting recording before pulling a stream is invalid.
|
|
530
|
+
- Do not switch between software and hardware decoding during recording; this may cause abnormal video output.
|
|
531
|
+
|
|
532
|
+
**Return Value**: `V2TXLiveCode`
|
|
533
|
+
- `V2TXLIVE_OK`: Success
|
|
534
|
+
- `V2TXLIVE_ERROR_INVALID_PARAMETER`: Invalid parameters (e.g., empty filePath)
|
|
535
|
+
- `V2TXLIVE_ERROR_REFUSED`: API refused, stream not started
|
|
536
|
+
|
|
537
|
+
**When to Call**: After playback has started.
|
|
538
|
+
|
|
539
|
+
**Example**:
|
|
540
|
+
```java
|
|
541
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
542
|
+
@Override
|
|
543
|
+
public void onLocalRecordBegin(V2TXLivePlayer player, int code, String storagePath) {
|
|
544
|
+
Log.i(TAG, "Recording started");
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
@Override
|
|
548
|
+
public void onLocalRecording(V2TXLivePlayer player, long durationMs, String storagePath) {
|
|
549
|
+
Log.i(TAG, "Recording..., durationMs: " + durationMs);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
@Override
|
|
553
|
+
public void onLocalRecordComplete(V2TXLivePlayer player, int code, String storagePath) {
|
|
554
|
+
Log.i(TAG, "Recording completed");
|
|
555
|
+
}
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
V2TXLiveDef.V2TXLiveLocalRecordingParams params = new V2TXLiveDef.V2TXLiveLocalRecordingParams();
|
|
559
|
+
params.filePath = "filepath";
|
|
560
|
+
params.interval = 2000;
|
|
561
|
+
int code = player.startLocalRecording(params);
|
|
562
|
+
if (code == V2TXLIVE_OK) {
|
|
563
|
+
Log.i(TAG, "Recording started successfully");
|
|
564
|
+
} else if (code == V2TXLIVE_ERROR_INVALID_PARAMETER) {
|
|
565
|
+
Log.i(TAG, "Invalid recording parameters");
|
|
566
|
+
} else if (code == V2TXLIVE_ERROR_REFUSED) {
|
|
567
|
+
Log.i(TAG, "Recording call refused");
|
|
568
|
+
}
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
### stopLocalRecording() - Stop Local Recording
|
|
572
|
+
```java
|
|
573
|
+
public abstract void stopLocalRecording()
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
**Description**: If the stream stops while recording is in progress, the SDK will automatically end the recording.
|
|
577
|
+
|
|
578
|
+
**When to Call**: After playback has started and recording is active.
|
|
579
|
+
|
|
580
|
+
**Example**:
|
|
581
|
+
```java
|
|
582
|
+
player.stopLocalRecording();
|
|
583
|
+
```
|
|
584
|
+
|
|
585
|
+
### showDebugView() - Show/Hide Debug Overlay
|
|
586
|
+
```java
|
|
587
|
+
public abstract void showDebugView(boolean isShow)
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
**Parameters**:
|
|
591
|
+
- `isShow`: true to show, false to hide. [Default]: false
|
|
592
|
+
|
|
593
|
+
**When to Call**: No restrictions.
|
|
594
|
+
|
|
595
|
+
**Example**:
|
|
596
|
+
```java
|
|
597
|
+
player.showDebugView(true);
|
|
598
|
+
```
|
|
599
|
+
|
|
600
|
+
### setProperty() - Advanced API Access
|
|
601
|
+
```java
|
|
602
|
+
public abstract int setProperty(String key, Object value)
|
|
603
|
+
```
|
|
604
|
+
|
|
605
|
+
**Parameters**:
|
|
606
|
+
- `key`: Advanced API key
|
|
607
|
+
- `value`: Parameter for the specified advanced API
|
|
608
|
+
|
|
609
|
+
**Description**: Use this method to access advanced features. For special requirements, contact your business or solution architect.
|
|
610
|
+
|
|
611
|
+
**Return Value**: `V2TXLiveCode`
|
|
612
|
+
- `V2TXLIVE_OK`: Success
|
|
613
|
+
- `V2TXLIVE_ERROR_INVALID_PARAMETER`: Key must not be null
|
|
614
|
+
|
|
615
|
+
#### enablePictureInPicture() - Enable Picture-in-Picture Mode (iOS Only)
|
|
616
|
+
```dart
|
|
617
|
+
Future<V2TXLiveCode> enablePictureInPicture(bool enable)
|
|
618
|
+
```
|
|
619
|
+
**Parameters**:
|
|
620
|
+
- `enable`: Enable Picture-in-Picture mode. Default: false
|
|
621
|
+
|
|
622
|
+
#### getTextureId() - Retrieve Texture ID
|
|
623
|
+
```dart
|
|
624
|
+
Future<int> getTextureId(int width, int height)
|
|
625
|
+
```
|
|
626
|
+
**Parameters**:
|
|
627
|
+
- `width`: Texture width
|
|
628
|
+
- `height`: Texture height
|
|
629
|
+
|
|
630
|
+
## Code Examples
|
|
631
|
+
|
|
632
|
+
```java
|
|
633
|
+
// Create player instance
|
|
634
|
+
V2TXLivePlayer player = V2TXLivePlayerImpl(context);
|
|
635
|
+
|
|
636
|
+
// Set callback
|
|
637
|
+
player.setObserver(new V2TXLivePlayerObserver() {
|
|
638
|
+
@Override
|
|
639
|
+
public void onConnected() {
|
|
640
|
+
// Connection successful callback
|
|
641
|
+
}
|
|
642
|
+
|
|
643
|
+
@Override
|
|
644
|
+
public void onVideoResolutionChanged(int width, int height) {
|
|
645
|
+
// Video resolution changed callback
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
// Set rendering view
|
|
650
|
+
player.setRenderView(videoView);
|
|
651
|
+
|
|
652
|
+
// Start playback
|
|
653
|
+
int result = player.startLivePlay("rtmp://example.com/live/stream");
|
|
654
|
+
if (result == V2TXLIVE_OK) {
|
|
655
|
+
// Playback successful
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
// Pause video
|
|
659
|
+
player.pauseVideo();
|
|
660
|
+
|
|
661
|
+
// Resume video
|
|
662
|
+
player.resumeVideo();
|
|
663
|
+
|
|
664
|
+
// Stop playback
|
|
665
|
+
player.stopPlay();
|
|
666
|
+
```
|
|
667
|
+
|
|
668
|
+
## Notes
|
|
669
|
+
|
|
670
|
+
1. **Licence Requirement**: Starting from version 10.7, you must set a valid Licence for playback.
|
|
671
|
+
2. **Permission Requirement**: Requires network and audio playback permissions.
|