@tencent-rtc/mcp 1.2.8 โ 1.2.9
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/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/tools/definitions/get_native_live_api_def.js +23 -0
- package/tools/definitions/get_native_live_api_def.js.map +1 -0
- package/tools/index.js +4 -0
- package/tools/index.js.map +1 -1
- package/tools/native_live/get-native-live-api.js +31 -0
- package/tools/native_live/get-native-live-api.js.map +1 -0
- package/utils/report-cls-client.js +1 -1
- package/utils/report-es-client.js +1 -1
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
# Tencent Cloud Live Streaming SDK V2TXLivePlayerObserver Callback Interface
|
|
2
|
+
|
|
3
|
+
## Feature Overview
|
|
4
|
+
|
|
5
|
+
`V2TXLivePlayerObserver.h` defines the callback interface for the Tencent Cloud Live Streaming SDK on iOS and macOS. This file includes all callback methods related to player status, audio/video events, statistics, error handling, local recording, and more.
|
|
6
|
+
|
|
7
|
+
**Platform Support**: iOS, macOS
|
|
8
|
+
**Feature Scope**: Player status monitoring, audio/video events, statistics, error handling, local recording, and more.
|
|
9
|
+
|
|
10
|
+
## ๐ Table of Contents
|
|
11
|
+
|
|
12
|
+
### 1. [Error and Warning Callbacks](#้่ฏฏๅ่ญฆๅๅ่ฐ)
|
|
13
|
+
### 2. [Connection Status Callbacks](#่ฟๆฅ็ถๆๅ่ฐ)
|
|
14
|
+
### 3. [Audio/Video Playback Events](#้ณ่ง้ขๆญๆพไบไปถ)
|
|
15
|
+
### 4. [Statistics Callbacks](#็ป่ฎกๆฐๆฎๅ่ฐ)
|
|
16
|
+
### 5. [Advanced Feature Callbacks](#้ซ็บงๅ่ฝๅ่ฐ)
|
|
17
|
+
### 6. [Local Recording Callbacks](#ๆฌๅฐๅฝๅถๅ่ฐ)
|
|
18
|
+
### 7. [Picture-in-Picture Status Callbacks](#็ปไธญ็ป็ถๆๅ่ฐ)
|
|
19
|
+
### 8. [Usage Examples](#ไฝฟ็จ็คบไพ)
|
|
20
|
+
|
|
21
|
+
## 1. Error and Warning Callbacks
|
|
22
|
+
|
|
23
|
+
### ๐ด onError - Player Error Callback
|
|
24
|
+
|
|
25
|
+
```objc
|
|
26
|
+
- (void)onError:(id<V2TXLivePlayer>)player
|
|
27
|
+
code:(V2TXLiveCode)code
|
|
28
|
+
message:(NSString *)msg
|
|
29
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Description**: Invoked when the player encounters an error.
|
|
33
|
+
|
|
34
|
+
**Parameters**:
|
|
35
|
+
- `player`: The player instance reporting the error
|
|
36
|
+
- `code`: Error code, see the `V2TXLiveCode` enum
|
|
37
|
+
- `msg`: Detailed error message
|
|
38
|
+
- `extraInfo`: Additional error context
|
|
39
|
+
|
|
40
|
+
**Common Scenarios**:
|
|
41
|
+
- Network connection failures
|
|
42
|
+
- Invalid stream URL
|
|
43
|
+
- Decoder errors
|
|
44
|
+
- Internal player errors
|
|
45
|
+
|
|
46
|
+
### โ ๏ธ onWarning - Player Warning Callback
|
|
47
|
+
|
|
48
|
+
```objc
|
|
49
|
+
- (void)onWarning:(id<V2TXLivePlayer>)player
|
|
50
|
+
code:(V2TXLiveCode)code
|
|
51
|
+
message:(NSString *)msg
|
|
52
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
**Description**: Invoked when the player encounters a warning.
|
|
56
|
+
|
|
57
|
+
**Parameters**:
|
|
58
|
+
- `player`: The player instance reporting the warning
|
|
59
|
+
- `code`: Warning code, see the `V2TXLiveCode` enum
|
|
60
|
+
- `msg`: Warning message
|
|
61
|
+
- `extraInfo`: Additional warning context
|
|
62
|
+
|
|
63
|
+
**Common Scenarios**:
|
|
64
|
+
- Poor network conditions
|
|
65
|
+
- Decoding performance issues
|
|
66
|
+
- Playback buffering warnings
|
|
67
|
+
|
|
68
|
+
## 2. Connection Status Callbacks
|
|
69
|
+
|
|
70
|
+
### ๐ onConnected - Connection Success Callback
|
|
71
|
+
|
|
72
|
+
```objc
|
|
73
|
+
- (void)onConnected:(id<V2TXLivePlayer>)player
|
|
74
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Description**: Invoked when the player successfully connects to the server.
|
|
78
|
+
|
|
79
|
+
**Parameters**:
|
|
80
|
+
- `player`: The player instance that connected
|
|
81
|
+
- `extraInfo`: Additional connection information
|
|
82
|
+
|
|
83
|
+
**Triggered When**:
|
|
84
|
+
- `startPlay` is called and connection is established
|
|
85
|
+
- Network reconnection succeeds
|
|
86
|
+
|
|
87
|
+
### ๐บ onVideoResolutionChanged - Video Resolution Change Callback
|
|
88
|
+
|
|
89
|
+
```objc
|
|
90
|
+
- (void)onVideoResolutionChanged:(id<V2TXLivePlayer>)player
|
|
91
|
+
width:(NSInteger)width
|
|
92
|
+
height:(NSInteger)height;
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
**Description**: Invoked when the video resolution changes.
|
|
96
|
+
|
|
97
|
+
**Parameters**:
|
|
98
|
+
- `player`: The player instance
|
|
99
|
+
- `width`: New video width
|
|
100
|
+
- `height`: New video height
|
|
101
|
+
|
|
102
|
+
**Common Scenarios**:
|
|
103
|
+
- Resolution changes during stream switching
|
|
104
|
+
- Resolution changes due to cloud stream mixing output
|
|
105
|
+
- Adaptive bitrate adjustments
|
|
106
|
+
|
|
107
|
+
## 3. Audio/Video Playback Events
|
|
108
|
+
|
|
109
|
+
### ๐ฌ onVideoPlaying - Video Playback Started
|
|
110
|
+
|
|
111
|
+
```objc
|
|
112
|
+
- (void)onVideoPlaying:(id<V2TXLivePlayer>)player
|
|
113
|
+
firstPlay:(BOOL)firstPlay
|
|
114
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Description**: Invoked when video playback starts.
|
|
118
|
+
|
|
119
|
+
**Parameters**:
|
|
120
|
+
- `player`: The player instance
|
|
121
|
+
- `firstPlay`: Indicates if this is the first playback
|
|
122
|
+
- `extraInfo`: Additional playback information
|
|
123
|
+
|
|
124
|
+
**Triggered When**:
|
|
125
|
+
- First successful video playback
|
|
126
|
+
- Playback resumes
|
|
127
|
+
|
|
128
|
+
### ๐ onAudioPlaying - Audio Playback Started
|
|
129
|
+
|
|
130
|
+
```objc
|
|
131
|
+
- (void)onAudioPlaying:(id<V2TXLivePlayer>)player
|
|
132
|
+
firstPlay:(BOOL)firstPlay
|
|
133
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
**Description**: Invoked when audio playback starts.
|
|
137
|
+
|
|
138
|
+
**Parameters**:
|
|
139
|
+
- `player`: The player instance
|
|
140
|
+
- `firstPlay`: Indicates if this is the first playback
|
|
141
|
+
- `extraInfo`: Additional playback information
|
|
142
|
+
|
|
143
|
+
### โณ onVideoLoading - Video Buffering Started
|
|
144
|
+
|
|
145
|
+
```objc
|
|
146
|
+
- (void)onVideoLoading:(id<V2TXLivePlayer>)player
|
|
147
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Description**: Invoked when the video is buffering or loading.
|
|
151
|
+
|
|
152
|
+
**Parameters**:
|
|
153
|
+
- `player`: The player instance
|
|
154
|
+
- `extraInfo`: Additional buffering information
|
|
155
|
+
|
|
156
|
+
**Triggered When**:
|
|
157
|
+
- Network buffering begins
|
|
158
|
+
- Player is preparing data
|
|
159
|
+
|
|
160
|
+
### โณ onAudioLoading - Audio Buffering Started
|
|
161
|
+
|
|
162
|
+
```objc
|
|
163
|
+
- (void)onAudioLoading:(id<V2TXLivePlayer>)player
|
|
164
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
**Description**: Invoked when the audio is buffering or loading.
|
|
168
|
+
|
|
169
|
+
## 4. Statistics Callbacks
|
|
170
|
+
|
|
171
|
+
### ๐ onStatisticsUpdate - Player Statistics Callback
|
|
172
|
+
|
|
173
|
+
```objc
|
|
174
|
+
- (void)onStatisticsUpdate:(id<V2TXLivePlayer>)player
|
|
175
|
+
statistics:(V2TXLivePlayerStatistics *)statistics;
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
**Description**: Periodically provides player statistics.
|
|
179
|
+
|
|
180
|
+
**Parameters**:
|
|
181
|
+
- `player`: The player instance
|
|
182
|
+
- `statistics`: Player statistics object
|
|
183
|
+
|
|
184
|
+
**Statistics Include**:
|
|
185
|
+
- Video width, height, frame rate, bitrate
|
|
186
|
+
- Audio bitrate, packet loss rate
|
|
187
|
+
- Stutter duration, stutter rate
|
|
188
|
+
- Network Round-Trip Time (RTT), download speed
|
|
189
|
+
|
|
190
|
+
**Frequency**: Every 2 seconds by default
|
|
191
|
+
|
|
192
|
+
### ๐ onPlayoutVolumeUpdate - Playback Volume Callback
|
|
193
|
+
|
|
194
|
+
```objc
|
|
195
|
+
- (void)onPlayoutVolumeUpdate:(id<V2TXLivePlayer>)player
|
|
196
|
+
volume:(NSInteger)volume;
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
**Description**: Provides real-time playback volume updates.
|
|
200
|
+
|
|
201
|
+
**Parameters**:
|
|
202
|
+
- `player`: The player instance
|
|
203
|
+
- `volume`: Current playback volume (0-100)
|
|
204
|
+
|
|
205
|
+
**Enablement**: Requires `enableVolumeEvaluation` to be called
|
|
206
|
+
|
|
207
|
+
**Frequency**: Every 100ms
|
|
208
|
+
|
|
209
|
+
## 5. Advanced Feature Callbacks
|
|
210
|
+
|
|
211
|
+
### ๐ธ onSnapshotComplete - Snapshot Completion Callback
|
|
212
|
+
|
|
213
|
+
```objc
|
|
214
|
+
- (void)onSnapshotComplete:(id<V2TXLivePlayer>)player
|
|
215
|
+
image:(nullable TXImage *)image;
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
**Description**: Invoked when a snapshot operation completes.
|
|
219
|
+
|
|
220
|
+
**Parameters**:
|
|
221
|
+
- `player`: The player instance
|
|
222
|
+
- `image`: Captured video frame image, or nil if failed
|
|
223
|
+
|
|
224
|
+
**Triggered When**: After calling the `snapshot` method
|
|
225
|
+
|
|
226
|
+
### ๐จ onRenderVideoFrame - Custom Video Rendering Callback
|
|
227
|
+
|
|
228
|
+
```objc
|
|
229
|
+
- (void)onRenderVideoFrame:(id<V2TXLivePlayer>)player
|
|
230
|
+
frame:(V2TXLiveVideoFrame *)videoFrame;
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
**Description**: Provides access to decoded video frames for custom rendering.
|
|
234
|
+
|
|
235
|
+
**Parameters**:
|
|
236
|
+
- `player`: The player instance
|
|
237
|
+
- `videoFrame`: Video frame data object
|
|
238
|
+
|
|
239
|
+
**Enablement**: Requires `enableObserveVideoFrame` to be called
|
|
240
|
+
|
|
241
|
+
**Use Cases**:
|
|
242
|
+
- Custom video processing
|
|
243
|
+
- Applying video filters
|
|
244
|
+
- Video analysis
|
|
245
|
+
|
|
246
|
+
### ๐ต onPlayoutAudioFrame - Audio Frame Callback
|
|
247
|
+
|
|
248
|
+
```objc
|
|
249
|
+
- (void)onPlayoutAudioFrame:(id<V2TXLivePlayer>)player
|
|
250
|
+
frame:(V2TXLiveAudioFrame *)audioFrame;
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Description**: Provides access to playback audio frames.
|
|
254
|
+
|
|
255
|
+
**Parameters**:
|
|
256
|
+
- `player`: The player instance
|
|
257
|
+
- `audioFrame`: Audio frame data object
|
|
258
|
+
|
|
259
|
+
**Enablement**: Requires `enableObserveAudioFrame` to be called
|
|
260
|
+
|
|
261
|
+
**Use Cases**:
|
|
262
|
+
- Real-time audio processing
|
|
263
|
+
- Audio analysis
|
|
264
|
+
- Applying audio effects
|
|
265
|
+
|
|
266
|
+
### ๐จ onReceiveSeiMessage - SEI Message Callback
|
|
267
|
+
|
|
268
|
+
```objc
|
|
269
|
+
- (void)onReceiveSeiMessage:(id<V2TXLivePlayer>)player
|
|
270
|
+
payloadType:(int)payloadType
|
|
271
|
+
data:(NSData *)data;
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
**Description**: Invoked when an SEI (Supplemental Enhancement Information) message is received.
|
|
275
|
+
|
|
276
|
+
**Parameters**:
|
|
277
|
+
- `player`: The player instance
|
|
278
|
+
- `payloadType`: SEI message payload type
|
|
279
|
+
- `data`: SEI message data
|
|
280
|
+
|
|
281
|
+
**Enablement**: Requires `enableReceiveSeiMessage` to be called
|
|
282
|
+
|
|
283
|
+
**Use Cases**:
|
|
284
|
+
- Time synchronization
|
|
285
|
+
- Scene description
|
|
286
|
+
- Custom business data
|
|
287
|
+
|
|
288
|
+
### ๐ onStreamSwitched - Stream Switch Callback
|
|
289
|
+
|
|
290
|
+
```objc
|
|
291
|
+
- (void)onStreamSwitched:(id<V2TXLivePlayer>)player
|
|
292
|
+
url:(NSString *)url
|
|
293
|
+
code:(NSInteger)code;
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
**Description**: Reports the result of seamless stream switching.
|
|
297
|
+
|
|
298
|
+
**Parameters**:
|
|
299
|
+
- `player`: The player instance
|
|
300
|
+
- `url`: Playback URL after switching
|
|
301
|
+
- `code`: Switch status code
|
|
302
|
+
- `0`: Success
|
|
303
|
+
- `-1`: Switch timeout
|
|
304
|
+
- `-2`: Server error
|
|
305
|
+
- `-3`: Client error
|
|
306
|
+
|
|
307
|
+
**Triggered When**: After calling `switchStream`
|
|
308
|
+
|
|
309
|
+
## 6. Local Recording Callbacks
|
|
310
|
+
|
|
311
|
+
### ๐ฌ onLocalRecordBegin - Recording Start Callback
|
|
312
|
+
|
|
313
|
+
```objc
|
|
314
|
+
- (void)onLocalRecordBegin:(id<V2TXLivePlayer>)player
|
|
315
|
+
errCode:(NSInteger)errCode
|
|
316
|
+
storagePath:(NSString *)storagePath;
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
**Description**: Invoked when a local recording task starts.
|
|
320
|
+
|
|
321
|
+
**Parameters**:
|
|
322
|
+
- `player`: The player instance
|
|
323
|
+
- `errCode`: Recording start status code
|
|
324
|
+
- `0`: Started successfully
|
|
325
|
+
- `-1`: Internal error
|
|
326
|
+
- `-2`: Unsupported file format
|
|
327
|
+
- `-6`: Recording already started
|
|
328
|
+
- `-7`: File already exists
|
|
329
|
+
- `-8`: No write permission for directory
|
|
330
|
+
- `storagePath`: Path to the recording file
|
|
331
|
+
|
|
332
|
+
**Triggered When**: After calling `startLocalRecording`
|
|
333
|
+
|
|
334
|
+
### โฑ๏ธ onLocalRecording - Recording Progress Callback
|
|
335
|
+
|
|
336
|
+
```objc
|
|
337
|
+
- (void)onLocalRecording:(id<V2TXLivePlayer>)player
|
|
338
|
+
durationMs:(NSInteger)durationMs
|
|
339
|
+
storagePath:(NSString *)storagePath;
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
**Description**: Reports progress during a recording task.
|
|
343
|
+
|
|
344
|
+
**Parameters**:
|
|
345
|
+
- `player`: The player instance
|
|
346
|
+
- `durationMs`: Current recording duration in milliseconds
|
|
347
|
+
- `storagePath`: Path to the recording file
|
|
348
|
+
|
|
349
|
+
**Enablement**: Set the callback interval when calling `startLocalRecording`
|
|
350
|
+
**Default**: No callback if not set
|
|
351
|
+
|
|
352
|
+
### โ
onLocalRecordComplete - Recording Completion Callback
|
|
353
|
+
|
|
354
|
+
```objc
|
|
355
|
+
- (void)onLocalRecordComplete:(id<V2TXLivePlayer>)player
|
|
356
|
+
errCode:(NSInteger)errCode
|
|
357
|
+
storagePath:(NSString *)storagePath;
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
**Description**: Invoked when a recording task completes.
|
|
361
|
+
|
|
362
|
+
**Parameters**:
|
|
363
|
+
- `player`: The player instance
|
|
364
|
+
- `errCode`: Recording completion status code
|
|
365
|
+
- `0`: Completed successfully
|
|
366
|
+
- `-1`: Recording failed
|
|
367
|
+
- `-2`: Ended due to resolution/orientation change
|
|
368
|
+
- `-3`: Recording too short or no data
|
|
369
|
+
- `storagePath`: Path to the recording file
|
|
370
|
+
|
|
371
|
+
**Triggered When**: After calling `stopLocalRecording`
|
|
372
|
+
|
|
373
|
+
## 7. Picture-in-Picture Status Callbacks
|
|
374
|
+
|
|
375
|
+
### ๐ผ๏ธ onPictureInPictureStateUpdate - Picture-in-Picture State Callback
|
|
376
|
+
|
|
377
|
+
```objc
|
|
378
|
+
- (void)onPictureInPictureStateUpdate:(id<V2TXLivePlayer>)player
|
|
379
|
+
state:(V2TXLivePictureInPictureState)state
|
|
380
|
+
message:(NSString *)msg
|
|
381
|
+
extraInfo:(NSDictionary *)extraInfo;
|
|
382
|
+
```
|
|
383
|
+
|
|
384
|
+
**Description**: Invoked when the picture-in-picture state changes.
|
|
385
|
+
|
|
386
|
+
**Parameters**:
|
|
387
|
+
- `player`: The player instance
|
|
388
|
+
- `state`: Picture-in-picture state, see `V2TXLivePictureInPictureState`
|
|
389
|
+
- `msg`: State description
|
|
390
|
+
- `extraInfo`: Additional information
|
|
391
|
+
|
|
392
|
+
**Supported States**:
|
|
393
|
+
- `V2TXLivePictureInPictureStateWillStart`: About to start
|
|
394
|
+
- `V2TXLivePictureInPictureStateDidStart`: Started
|
|
395
|
+
- `V2TXLivePictureInPictureStateWillStop`: About to stop
|
|
396
|
+
- `V2TXLivePictureInPictureStateDidStop`: Stopped
|
|
397
|
+
- `V2TXLivePictureInPictureStateRestoreUI`: Restore UI
|
|
398
|
+
|
|
399
|
+
**Enablement**: Requires `enablePictureInPicture` to be called
|
|
400
|
+
|
|
401
|
+
## 8. Usage Examples
|
|
402
|
+
|
|
403
|
+
### ๐ง Basic Player Observer Implementation
|
|
404
|
+
|
|
405
|
+
```objc
|
|
406
|
+
@interface MyPlayerObserver : NSObject <V2TXLivePlayerObserver>
|
|
407
|
+
@end
|
|
408
|
+
|
|
409
|
+
@implementation MyPlayerObserver
|
|
410
|
+
|
|
411
|
+
#pragma mark - Error Handling
|
|
412
|
+
- (void)onError:(id<V2TXLivePlayer>)player code:(V2TXLiveCode)code message:(NSString *)msg extraInfo:(NSDictionary *)extraInfo {
|
|
413
|
+
NSLog(@"Player error: %@, error code: %ld", msg, (long)code);
|
|
414
|
+
// Handle playback error
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
#pragma mark - Connection Status
|
|
418
|
+
- (void)onConnected:(id<V2TXLivePlayer>)player extraInfo:(NSDictionary *)extraInfo {
|
|
419
|
+
NSLog(@"Player connected successfully");
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
#pragma mark - Playback Events
|
|
423
|
+
- (void)onVideoPlaying:(id<V2TXLivePlayer>)player firstPlay:(BOOL)firstPlay extraInfo:(NSDictionary *)extraInfo {
|
|
424
|
+
if (firstPlay) {
|
|
425
|
+
NSLog(@"Video played successfully for the first time");
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
#pragma mark - Statistics
|
|
430
|
+
- (void)onStatisticsUpdate:(id<V2TXLivePlayer>)player statistics:(V2TXLivePlayerStatistics *)statistics {
|
|
431
|
+
NSLog(@"Video FPS: %ld, Bitrate: %ld Kbps", statistics.fps, statistics.videoBitrate);
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
@end
|
|
435
|
+
```
|
|
436
|
+
|
|
437
|
+
### ๐ Volume Monitoring Example
|
|
438
|
+
|
|
439
|
+
```objc
|
|
440
|
+
// Enable volume evaluation
|
|
441
|
+
[player enableVolumeEvaluation:100]; // Callback every 100ms
|
|
442
|
+
|
|
443
|
+
// Volume callback implementation
|
|
444
|
+
- (void)onPlayoutVolumeUpdate:(id<V2TXLivePlayer>)player volume:(NSInteger)volume {
|
|
445
|
+
// Update UI volume indicator
|
|
446
|
+
[self updateVolumeIndicator:volume];
|
|
447
|
+
}
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
### ๐ฌ Local Recording Example
|
|
451
|
+
|
|
452
|
+
```objc
|
|
453
|
+
// Start recording
|
|
454
|
+
V2TXLiveLocalRecordingParams *params = [[V2TXLiveLocalRecordingParams alloc] init];
|
|
455
|
+
params.filePath = @"/path/to/record.mp4";
|
|
456
|
+
params.recordMode = V2TXLiveRecordModeBoth;
|
|
457
|
+
params.interval = 1000; // Callback recording progress every 1 second
|
|
458
|
+
|
|
459
|
+
[player startLocalRecording:params];
|
|
460
|
+
|
|
461
|
+
// Recording callback implementation
|
|
462
|
+
- (void)onLocalRecording:(id<V2TXLivePlayer>)player durationMs:(NSInteger)durationMs storagePath:(NSString *)storagePath {
|
|
463
|
+
NSLog(@"Recording progress: %.1f seconds", durationMs / 1000.0);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
- (void)onLocalRecordComplete:(id<V2TXLivePlayer>)player errCode:(NSInteger)errCode storagePath:(NSString *)storagePath {
|
|
467
|
+
if (errCode == 0) {
|
|
468
|
+
NSLog(@"Recording completed, file path: %@", storagePath);
|
|
469
|
+
} else {
|
|
470
|
+
NSLog(@"Recording failed, error code: %ld", (long)errCode);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
```
|
|
474
|
+
|
|
475
|
+
### ๐จ Custom Video Frame Processing
|
|
476
|
+
|
|
477
|
+
```objc
|
|
478
|
+
// Enable video frame callback
|
|
479
|
+
[player enableObserveVideoFrame:YES pixelFormat:V2TXLivePixelFormatNV12];
|
|
480
|
+
|
|
481
|
+
// Video frame processing callback
|
|
482
|
+
- (void)onRenderVideoFrame:(id<V2TXLivePlayer>)player frame:(V2TXLiveVideoFrame *)videoFrame {
|
|
483
|
+
// Custom video processing logic
|
|
484
|
+
[self processVideoFrame:videoFrame];
|
|
485
|
+
}
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
## ๐ Best Practices
|
|
489
|
+
|
|
490
|
+
### ๐ง Callback Handling Recommendations
|
|
491
|
+
|
|
492
|
+
1. **Error Handling**: Implement robust error recovery in `onError`.
|
|
493
|
+
2. **Performance Monitoring**: Use `onStatisticsUpdate` to monitor playback quality.
|
|
494
|
+
3. **User Experience**: Improve UI feedback by leveraging playback event callbacks.
|
|
495
|
+
4. **Resource Management**: Release resources used in callbacks promptly.
|
|
496
|
+
|
|
497
|
+
### โก Performance Optimization
|
|
498
|
+
|
|
499
|
+
1. **Callback Frequency**: Set appropriate frequencies for statistics and volume callbacks.
|
|
500
|
+
2. **Thread Safety**: Ensure all UI updates in callbacks are performed on the main thread.
|
|
501
|
+
3. **Memory Management**: Avoid creating unnecessary temporary objects in callbacks.
|
|
502
|
+
|
|
503
|
+
### ๐ Exception Handling
|
|
504
|
+
|
|
505
|
+
1. **Network Exceptions**: Implement auto-reconnect and fallback strategies.
|
|
506
|
+
2. **Decoding Exceptions**: Prepare backup decoding solutions.
|
|
507
|
+
3. **Recording Exceptions**: Handle file permissions and storage space issues.
|