agora-electron-sdk 4.2.0 → 4.2.2-dev.4

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.
Files changed (103) hide show
  1. package/js/AgoraSdk.js +7 -5
  2. package/js/Private/AgoraBase.js +394 -1292
  3. package/js/Private/AgoraMediaBase.js +76 -340
  4. package/js/Private/AgoraMediaPlayerTypes.js +25 -122
  5. package/js/Private/IAgoraLog.js +5 -14
  6. package/js/Private/IAgoraMediaEngine.js +5 -2
  7. package/js/Private/IAgoraMediaPlayer.js +10 -4
  8. package/js/Private/IAgoraMediaRecorder.js +5 -2
  9. package/js/Private/IAgoraMediaStreamingSource.js +5 -12
  10. package/js/Private/IAgoraMusicContentCenter.js +68 -125
  11. package/js/Private/IAgoraRhythmPlayer.js +5 -10
  12. package/js/Private/IAgoraRtcEngine.js +141 -932
  13. package/js/Private/IAgoraRtcEngineEx.js +29 -13
  14. package/js/Private/IAgoraSpatialAudio.js +40 -53
  15. package/js/Private/IAudioDeviceManager.js +5 -2
  16. package/js/Private/impl/IAgoraMediaEngineImpl.js +156 -139
  17. package/js/Private/impl/IAgoraMediaPlayerImpl.js +538 -526
  18. package/js/Private/impl/IAgoraMediaRecorderImpl.js +29 -26
  19. package/js/Private/impl/IAgoraMusicContentCenterImpl.js +264 -192
  20. package/js/Private/impl/IAgoraRtcEngineExImpl.js +419 -399
  21. package/js/Private/impl/IAgoraRtcEngineImpl.js +2352 -2207
  22. package/js/Private/impl/IAgoraSpatialAudioImpl.js +192 -169
  23. package/js/Private/impl/IAudioDeviceManagerImpl.js +235 -232
  24. package/js/Private/internal/AudioDeviceManagerInternal.js +44 -24
  25. package/js/Private/internal/IrisApiEngine.js +109 -76
  26. package/js/Private/internal/LocalSpatialAudioEngineInternal.js +49 -29
  27. package/js/Private/internal/MediaEngineInternal.js +82 -58
  28. package/js/Private/internal/MediaPlayerInternal.js +132 -111
  29. package/js/Private/internal/MediaRecorderInternal.js +64 -38
  30. package/js/Private/internal/MusicContentCenterInternal.js +130 -100
  31. package/js/Private/internal/RtcEngineExInternal.js +265 -219
  32. package/js/Private/ti/AgoraBase-ti.js +2 -2
  33. package/js/Private/ti/AgoraMediaBase-ti.js +15 -15
  34. package/js/Private/ti/AgoraMediaPlayerTypes-ti.js +1 -1
  35. package/js/Private/ti/IAgoraLog-ti.js +1 -1
  36. package/js/Private/ti/IAgoraMediaEngine-ti.js +1 -1
  37. package/js/Private/ti/IAgoraMediaPlayer-ti.js +2 -2
  38. package/js/Private/ti/IAgoraMediaPlayerSource-ti.js +2 -2
  39. package/js/Private/ti/IAgoraMediaRecorder-ti.js +1 -1
  40. package/js/Private/ti/IAgoraMediaStreamingSource-ti.js +1 -1
  41. package/js/Private/ti/IAgoraMusicContentCenter-ti.js +5 -4
  42. package/js/Private/ti/IAgoraRhythmPlayer-ti.js +1 -1
  43. package/js/Private/ti/IAgoraRtcEngine-ti.js +2 -2
  44. package/js/Private/ti/IAgoraRtcEngineEx-ti.js +1 -1
  45. package/js/Private/ti/IAgoraSpatialAudio-ti.js +1 -1
  46. package/js/Private/ti/IAudioDeviceManager-ti.js +1 -1
  47. package/js/Renderer/AgoraView.js +145 -100
  48. package/js/Renderer/IRenderer.js +18 -17
  49. package/js/Renderer/IRendererManager.js +5 -2
  50. package/js/Renderer/RendererManager.js +208 -180
  51. package/js/Renderer/WebGLRenderer/index.js +111 -107
  52. package/js/Renderer/YUVCanvasRenderer/index.js +68 -51
  53. package/js/Utils.js +85 -36
  54. package/package.json +3 -3
  55. package/ts/AgoraSdk.ts +3 -1
  56. package/ts/Private/AgoraBase.ts +227 -86
  57. package/ts/Private/AgoraMediaBase.ts +69 -54
  58. package/ts/Private/AgoraMediaPlayerTypes.ts +4 -4
  59. package/ts/Private/IAgoraLog.ts +1 -1
  60. package/ts/Private/IAgoraMediaEngine.ts +42 -39
  61. package/ts/Private/IAgoraMediaPlayer.ts +98 -67
  62. package/ts/Private/IAgoraMediaPlayerSource.ts +15 -8
  63. package/ts/Private/IAgoraMusicContentCenter.ts +25 -4
  64. package/ts/Private/IAgoraRtcEngine.ts +951 -747
  65. package/ts/Private/IAgoraRtcEngineEx.ts +183 -157
  66. package/ts/Private/IAgoraSpatialAudio.ts +55 -32
  67. package/ts/Private/IAudioDeviceManager.ts +39 -25
  68. package/ts/Private/impl/IAgoraMusicContentCenterImpl.ts +72 -21
  69. package/ts/Private/impl/IAgoraRtcEngineImpl.ts +136 -15
  70. package/ts/Private/internal/RtcEngineExInternal.ts +8 -0
  71. package/ts/Private/ti/AgoraMediaBase-ti.ts +13 -13
  72. package/ts/Private/ti/IAgoraMusicContentCenter-ti.ts +3 -2
  73. package/types/AgoraSdk.d.ts +3 -1
  74. package/types/AgoraSdk.d.ts.map +1 -1
  75. package/types/Private/AgoraBase.d.ts +221 -86
  76. package/types/Private/AgoraBase.d.ts.map +1 -1
  77. package/types/Private/AgoraMediaBase.d.ts +69 -51
  78. package/types/Private/AgoraMediaBase.d.ts.map +1 -1
  79. package/types/Private/AgoraMediaPlayerTypes.d.ts +4 -4
  80. package/types/Private/IAgoraLog.d.ts +1 -1
  81. package/types/Private/IAgoraMediaEngine.d.ts +42 -39
  82. package/types/Private/IAgoraMediaEngine.d.ts.map +1 -1
  83. package/types/Private/IAgoraMediaPlayer.d.ts +98 -67
  84. package/types/Private/IAgoraMediaPlayer.d.ts.map +1 -1
  85. package/types/Private/IAgoraMediaPlayerSource.d.ts +15 -8
  86. package/types/Private/IAgoraMediaPlayerSource.d.ts.map +1 -1
  87. package/types/Private/IAgoraMusicContentCenter.d.ts +17 -5
  88. package/types/Private/IAgoraMusicContentCenter.d.ts.map +1 -1
  89. package/types/Private/IAgoraRtcEngine.d.ts +936 -744
  90. package/types/Private/IAgoraRtcEngine.d.ts.map +1 -1
  91. package/types/Private/IAgoraRtcEngineEx.d.ts +183 -157
  92. package/types/Private/IAgoraRtcEngineEx.d.ts.map +1 -1
  93. package/types/Private/IAgoraSpatialAudio.d.ts +55 -32
  94. package/types/Private/IAgoraSpatialAudio.d.ts.map +1 -1
  95. package/types/Private/IAudioDeviceManager.d.ts +39 -25
  96. package/types/Private/IAudioDeviceManager.d.ts.map +1 -1
  97. package/types/Private/impl/IAgoraMusicContentCenterImpl.d.ts +9 -5
  98. package/types/Private/impl/IAgoraMusicContentCenterImpl.d.ts.map +1 -1
  99. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts +18 -6
  100. package/types/Private/impl/IAgoraRtcEngineImpl.d.ts.map +1 -1
  101. package/types/Private/internal/RtcEngineExInternal.d.ts +1 -0
  102. package/types/Private/internal/RtcEngineExInternal.d.ts.map +1 -1
  103. package/types/Private/ti/IAgoraMusicContentCenter-ti.d.ts.map +1 -1
@@ -23,39 +23,42 @@ export abstract class IMediaPlayer {
23
23
  * Gets the ID of the media player.
24
24
  *
25
25
  * @returns
26
- * ≥ 0: Success. The ID of the media player.< 0: Failure.
26
+ * ≥ 0: Success. The ID of the media player. < 0: Failure.
27
27
  */
28
28
  abstract getMediaPlayerId(): number;
29
29
 
30
30
  /**
31
31
  * Opens the media resource.
32
- * This method is called asynchronously.If you need to play a media file, make sure you receive the onPlayerSourceStateChanged callback reporting PlayerStateOpenCompleted before calling the play method to play the file.
32
+ *
33
+ * This method is called asynchronously. If you need to play a media file, make sure you receive the onPlayerSourceStateChanged callback reporting PlayerStateOpenCompleted before calling the play method to play the file.
33
34
  *
34
35
  * @param url The path of the media file. Both local path and online path are supported.
35
36
  * @param startPos The starting position (ms) for playback. Default value is 0.
36
37
  *
37
38
  * @returns
38
- * 0: Success.< 0: Failure.
39
+ * 0: Success. < 0: Failure.
39
40
  */
40
41
  abstract open(url: string, startPos: number): number;
41
42
 
42
43
  /**
43
44
  * Opens a media file and configures the playback scenarios.
45
+ *
44
46
  * This method supports opening media files of different sources, including a custom media source, and allows you to configure the playback scenarios.
45
47
  *
46
- * @param source Media resources. See MediaSource .
48
+ * @param source Media resources. See MediaSource.
47
49
  *
48
50
  * @returns
49
- * 0: Success.< 0: Failure.
51
+ * 0: Success. < 0: Failure.
50
52
  */
51
53
  abstract openWithMediaSource(source: MediaSource): number;
52
54
 
53
55
  /**
54
56
  * Plays the media file.
55
- * After calling open or seek, you can call this method to play the media file.
57
+ *
58
+ * After calling open or seek , you can call this method to play the media file.
56
59
  *
57
60
  * @returns
58
- * 0: Success.< 0: Failure.
61
+ * 0: Success. < 0: Failure.
59
62
  */
60
63
  abstract play(): number;
61
64
 
@@ -63,7 +66,7 @@ export abstract class IMediaPlayer {
63
66
  * Pauses the playback.
64
67
  *
65
68
  * @returns
66
- * 0: Success.< 0: Failure.
69
+ * 0: Success. < 0: Failure.
67
70
  */
68
71
  abstract pause(): number;
69
72
 
@@ -71,7 +74,7 @@ export abstract class IMediaPlayer {
71
74
  * Stops playing the media track.
72
75
  *
73
76
  * @returns
74
- * 0: Success.< 0: Failure.
77
+ * 0: Success. < 0: Failure.
75
78
  */
76
79
  abstract stop(): number;
77
80
 
@@ -79,29 +82,31 @@ export abstract class IMediaPlayer {
79
82
  * Resumes playing the media file.
80
83
  *
81
84
  * @returns
82
- * 0: Success.< 0: Failure.
85
+ * 0: Success. < 0: Failure.
83
86
  */
84
87
  abstract resume(): number;
85
88
 
86
89
  /**
87
90
  * Seeks to a new playback position.
88
- * fter successfully calling this method, you will receive the onPlayerEvent callback, reporting the result of the seek operation to the new playback position.To play the media file from a specific position, do the following:Call this method to seek to the position you want to begin playback.Call the play method to play the media file.
91
+ *
92
+ * fter successfully calling this method, you will receive the onPlayerEvent callback, reporting the result of the seek operation to the new playback position. To play the media file from a specific position, do the following: Call this method to seek to the position you want to begin playback. Call the play method to play the media file.
89
93
  *
90
94
  * @param newPos The new playback position (ms).
91
95
  *
92
96
  * @returns
93
- * 0: Success.< 0: Failure.
97
+ * 0: Success. < 0: Failure.
94
98
  */
95
99
  abstract seek(newPos: number): number;
96
100
 
97
101
  /**
98
102
  * Sets the pitch of the current media resource.
103
+ *
99
104
  * Call this method after calling open .
100
105
  *
101
106
  * @param pitch Sets the pitch of the local music file by the chromatic scale. The default value is 0, which means keeping the original pitch. The value ranges from -12 to 12, and the pitch value between consecutive values is a chromatic value. The greater the absolute value of this parameter, the higher or lower the pitch of the local music file.
102
107
  *
103
108
  * @returns
104
- * 0: Success.< 0: Failure.
109
+ * 0: Success. < 0: Failure.
105
110
  */
106
111
  abstract setAudioPitch(pitch: number): number;
107
112
 
@@ -117,60 +122,65 @@ export abstract class IMediaPlayer {
117
122
  * Gets current local playback progress.
118
123
  *
119
124
  * @returns
120
- * Returns the current playback progress (ms) if the call succeeds.< 0: Failure. See MediaPlayerError .
125
+ * Returns the current playback progress (ms) if the call succeeds. < 0: Failure. See MediaPlayerError .
121
126
  */
122
127
  abstract getPlayPosition(): number;
123
128
 
124
129
  /**
125
130
  * Gets the number of the media streams in the media resource.
131
+ *
126
132
  * Call this method after calling open .
127
133
  *
128
134
  * @returns
129
- * The number of the media streams in the media resource if the method call succeeds.< 0: Failure. See MediaPlayerError .
135
+ * The number of the media streams in the media resource if the method call succeeds. < 0: Failure. See MediaPlayerError .
130
136
  */
131
137
  abstract getStreamCount(): number;
132
138
 
133
139
  /**
134
140
  * Gets the detailed information of the media stream.
141
+ *
135
142
  * Call this method after calling getStreamCount .
136
143
  *
137
144
  * @param index The index of the media stream.
138
145
  *
139
146
  * @returns
140
- * If the call succeeds, returns the detailed information of the media stream. See PlayerStreamInfo .If the call fails, returns NULL.
147
+ * If the call succeeds, returns the detailed information of the media stream. See PlayerStreamInfo . If the call fails, returns NULL .
141
148
  */
142
149
  abstract getStreamInfo(index: number): PlayerStreamInfo;
143
150
 
144
151
  /**
145
152
  * Sets the loop playback.
146
- * If you want to loop, call this method and set the number of the loops.When the loop finishes, the SDK triggers onPlayerSourceStateChanged and reports the playback state as PlayerStatePlaybackAllLoopsCompleted.
153
+ *
154
+ * If you want to loop, call this method and set the number of the loops. When the loop finishes, the SDK triggers onPlayerSourceStateChanged and reports the playback state as PlayerStatePlaybackAllLoopsCompleted .
147
155
  *
148
156
  * @param loopCount The number of times the audio effect loops:
149
157
  *
150
158
  * @returns
151
- * 0: Success.< 0: Failure.
159
+ * 0: Success. < 0: Failure.
152
160
  */
153
161
  abstract setLoopCount(loopCount: number): number;
154
162
 
155
163
  /**
156
164
  * Sets the channel mode of the current audio file.
165
+ *
157
166
  * Call this method after calling open .
158
167
  *
159
168
  * @param speed The playback speed. Agora recommends that you limit this value to between 50 and 400, defined as follows:50: Half the original speed.100: The original speed.400: 4 times the original speed.
160
169
  *
161
170
  * @returns
162
- * 0: Success.< 0: Failure.
171
+ * 0: Success. < 0: Failure.
163
172
  */
164
173
  abstract setPlaybackSpeed(speed: number): number;
165
174
 
166
175
  /**
167
176
  * Selects the audio track used during playback.
168
- * After getting the track index of the audio file, you can call this method to specify any track to play. For example, if different tracks of a multi-track file store songs in different languages, you can call this method to set the playback language.You need to call this method after calling getStreamInfo to get the audio stream index value.
177
+ *
178
+ * After getting the track index of the audio file, you can call this method to specify any track to play. For example, if different tracks of a multi-track file store songs in different languages, you can call this method to set the playback language. You need to call this method after calling getStreamInfo to get the audio stream index value.
169
179
  *
170
180
  * @param index The index of the audio track.
171
181
  *
172
182
  * @returns
173
- * 0: Success.< 0: Failure.
183
+ * 0: Success. < 0: Failure.
174
184
  */
175
185
  abstract selectAudioTrack(index: number): number;
176
186
 
@@ -181,13 +191,14 @@ export abstract class IMediaPlayer {
181
191
 
182
192
  /**
183
193
  * Sets the private options for the media player.
184
- * The media player supports setting private options by key and value. Under normal circumstances, you do not need to know the private option settings, and just use the default option settings.Ensure that you call this method before open .If you need to push streams with SEI into the CDN, call setPlayerOptionInString("sei_data_with_uuid", 1); otherwise, the loss of SEI might occurs.
194
+ *
195
+ * The media player supports setting private options by key and value. Under normal circumstances, you do not need to know the private option settings, and just use the default option settings. Ensure that you call this method before open . If you need to push streams with SEI into the CDN, call setPlayerOptionInString ("sei_data_with_uuid", 1) ; otherwise, the loss of SEI might occurs.
185
196
  *
186
197
  * @param key The key of the option.
187
198
  * @param value The value of the key.
188
199
  *
189
200
  * @returns
190
- * 0: Success.< 0: Failure.
201
+ * 0: Success. < 0: Failure.
191
202
  */
192
203
  abstract setPlayerOptionInString(key: string, value: string): number;
193
204
 
@@ -220,7 +231,7 @@ export abstract class IMediaPlayer {
220
231
  * @param muted Whether to mute the media file:true: Mute the media file.false: (Default) Unmute the media file.
221
232
  *
222
233
  * @returns
223
- * 0: Success.< 0: Failure.
234
+ * 0: Success. < 0: Failure.
224
235
  */
225
236
  abstract mute(muted: boolean): number;
226
237
 
@@ -228,7 +239,7 @@ export abstract class IMediaPlayer {
228
239
  * Reports whether the media resource is muted.
229
240
  *
230
241
  * @returns
231
- * true: Reports whether the media resource is muted.false: Reports whether the media resource is muted.
242
+ * true : Reports whether the media resource is muted. false : Reports whether the media resource is muted.
232
243
  */
233
244
  abstract getMute(): boolean;
234
245
 
@@ -238,7 +249,7 @@ export abstract class IMediaPlayer {
238
249
  * @param volume The local playback volume, which ranges from 0 to 100:0: Mute.100: (Default) The original volume.
239
250
  *
240
251
  * @returns
241
- * 0: Success.< 0: Failure.
252
+ * 0: Success. < 0: Failure.
242
253
  */
243
254
  abstract adjustPlayoutVolume(volume: number): number;
244
255
 
@@ -246,18 +257,19 @@ export abstract class IMediaPlayer {
246
257
  * Gets the local playback volume.
247
258
  *
248
259
  * @returns
249
- * The local playback volume, which ranges from 0 to 100.0: Mute.100: (Default) The original volume.
260
+ * The local playback volume, which ranges from 0 to 100. 0: Mute. 100: (Default) The original volume.
250
261
  */
251
262
  abstract getPlayoutVolume(): number;
252
263
 
253
264
  /**
254
265
  * Adjusts the volume of the media file for publishing.
266
+ *
255
267
  * After connected to the Agora server, you can call this method to adjust the volume of the media file heard by the remote user.
256
268
  *
257
269
  * @param volume The volume, which ranges from 0 to 400:0: Mute.100: (Default) The original volume.400: Four times the original volume (amplifying the audio signals by four times).
258
270
  *
259
271
  * @returns
260
- * 0: Success.< 0: Failure.
272
+ * 0: Success. < 0: Failure.
261
273
  */
262
274
  abstract adjustPublishSignalVolume(volume: number): number;
263
275
 
@@ -265,7 +277,7 @@ export abstract class IMediaPlayer {
265
277
  * Gets the volume of the media file for publishing.
266
278
  *
267
279
  * @returns
268
- * ≥ 0: The remote playback volume.< 0: Failure.
280
+ * ≥ 0: The remote playback volume. < 0: Failure.
269
281
  */
270
282
  abstract getPublishSignalVolume(): number;
271
283
 
@@ -273,27 +285,27 @@ export abstract class IMediaPlayer {
273
285
  * Sets the view.
274
286
  *
275
287
  * @returns
276
- * 0: Success.< 0: Failure.
288
+ * 0: Success. < 0: Failure.
277
289
  */
278
290
  abstract setView(view: any): number;
279
291
 
280
292
  /**
281
293
  * Sets the render mode of the media player.
282
294
  *
283
- * @param renderMode Sets the render mode of the view. See RenderModeType .
295
+ * @param renderMode Sets the render mode of the view. See RenderModeType.
284
296
  *
285
297
  * @returns
286
- * 0: Success.< 0: Failure.
298
+ * 0: Success. < 0: Failure.
287
299
  */
288
300
  abstract setRenderMode(renderMode: RenderModeType): number;
289
301
 
290
302
  /**
291
303
  * Registers a media player observer.
292
304
  *
293
- * @param observer The player observer, listening for events during the playback. See IMediaPlayerSourceObserver .
305
+ * @param observer The player observer, listening for events during the playback. See IMediaPlayerSourceObserver.
294
306
  *
295
307
  * @returns
296
- * 0: Success.< 0: Failure.
308
+ * 0: Success. < 0: Failure.
297
309
  */
298
310
  abstract registerPlayerSourceObserver(
299
311
  observer: IMediaPlayerSourceObserver
@@ -302,10 +314,10 @@ export abstract class IMediaPlayer {
302
314
  /**
303
315
  * Releases a media player observer.
304
316
  *
305
- * @param observer The player observer, listening for events during the playback. See IMediaPlayerSourceObserver .
317
+ * @param observer The player observer, listening for events during the playback. See IMediaPlayerSourceObserver.
306
318
  *
307
319
  * @returns
308
- * 0: Success.< 0: Failure.
320
+ * 0: Success. < 0: Failure.
309
321
  */
310
322
  abstract unregisterPlayerSourceObserver(
311
323
  observer: IMediaPlayerSourceObserver
@@ -314,11 +326,11 @@ export abstract class IMediaPlayer {
314
326
  /**
315
327
  * Registers an audio frame observer object.
316
328
  *
317
- * @param observer The audio frame observer, reporting the reception of each audio frame. See IAudioPcmFrameSink .
318
- * @param mode The use mode of the audio frame. See RawAudioFrameOpModeType .
329
+ * @param observer The audio frame observer, reporting the reception of each audio frame. See IAudioPcmFrameSink.
330
+ * @param mode The use mode of the audio frame. See RawAudioFrameOpModeType.
319
331
  *
320
332
  * @returns
321
- * 0: Success.< 0: Failure.
333
+ * 0: Success. < 0: Failure.
322
334
  */
323
335
  abstract registerAudioFrameObserver(
324
336
  observer: IAudioPcmFrameSink,
@@ -328,21 +340,22 @@ export abstract class IMediaPlayer {
328
340
  /**
329
341
  * Unregisters an audio frame observer.
330
342
  *
331
- * @param observer The audio observer. See IAudioPcmFrameSink .
343
+ * @param observer The audio observer. See IAudioPcmFrameSink.
332
344
  *
333
345
  * @returns
334
- * 0: Success.< 0: Failure.
346
+ * 0: Success. < 0: Failure.
335
347
  */
336
348
  abstract unregisterAudioFrameObserver(observer: IAudioPcmFrameSink): number;
337
349
 
338
350
  /**
339
351
  * Registers a video frame observer object.
352
+ *
340
353
  * You need to implement the IMediaPlayerVideoFrameObserver class in this method and register callbacks according to your scenarios. After you successfully register the video frame observer, the SDK triggers the registered callbacks each time a video frame is received.
341
354
  *
342
- * @param observer The video observer, reporting the reception of each video frame. See IMediaPlayerVideoFrameObserver .
355
+ * @param observer The video observer, reporting the reception of each video frame. See IMediaPlayerVideoFrameObserver.
343
356
  *
344
357
  * @returns
345
- * 0: Success.< 0: Failure.
358
+ * 0: Success. < 0: Failure.
346
359
  */
347
360
  abstract registerVideoFrameObserver(
348
361
  observer: IMediaPlayerVideoFrameObserver
@@ -351,10 +364,10 @@ export abstract class IMediaPlayer {
351
364
  /**
352
365
  * Unregisters the video frame observer.
353
366
  *
354
- * @param observer The video observer, reporting the reception of each video frame. See IMediaPlayerVideoFrameObserver .
367
+ * @param observer The video observer, reporting the reception of each video frame. See IMediaPlayerVideoFrameObserver.
355
368
  *
356
369
  * @returns
357
- * 0: Success.< 0: Failure.
370
+ * 0: Success. < 0: Failure.
358
371
  */
359
372
  abstract unregisterVideoFrameObserver(
360
373
  observer: IMediaPlayerVideoFrameObserver
@@ -377,12 +390,13 @@ export abstract class IMediaPlayer {
377
390
 
378
391
  /**
379
392
  * Sets the channel mode of the current audio file.
380
- * In a stereo music file, the left and right channels can store different audio data. According to your needs, you can set the channel mode to original mode, left channel mode, right channel mode, or mixed channel mode. For example, in the KTV scenario, the left channel of the music file stores the musical accompaniment, and the right channel stores the singing voice. If you only need to listen to the accompaniment, call this method to set the channel mode of the music file to left channel mode; if you need to listen to the accompaniment and the singing voice at the same time, call this method to set the channel mode to mixed channel mode.Call this method after calling open .This method only applies to stereo audio files.
381
393
  *
382
- * @param mode The channel mode. See AudioDualMonoMode .
394
+ * In a stereo music file, the left and right channels can store different audio data. According to your needs, you can set the channel mode to original mode, left channel mode, right channel mode, or mixed channel mode. For example, in the KTV scenario, the left channel of the music file stores the musical accompaniment, and the right channel stores the singing voice. If you only need to listen to the accompaniment, call this method to set the channel mode of the music file to left channel mode; if you need to listen to the accompaniment and the singing voice at the same time, call this method to set the channel mode to mixed channel mode. Call this method after calling open . This method only applies to stereo audio files.
395
+ *
396
+ * @param mode The channel mode. See AudioDualMonoMode.
383
397
  *
384
398
  * @returns
385
- * 0: Success.< 0: Failure.
399
+ * 0: Success. < 0: Failure.
386
400
  */
387
401
  abstract setAudioDualMonoMode(mode: AudioDualMonoMode): number;
388
402
 
@@ -436,56 +450,61 @@ export abstract class IMediaPlayer {
436
450
 
437
451
  /**
438
452
  * Switches the media resource being played.
439
- * You can call this method to switch the media resource to be played according to the current network status. For example:When the network is poor, the media resource to be played is switched to a media resource address with a lower bitrate.When the network is good, the media resource to be played is switched to a media resource address with a higher bitrate.After calling this method, if you receive the PlayerEventSwitchComplete event in the onPlayerEvent callback, the switch is successful; If you receive the PlayerEventSwitchError event in the onPlayerEvent callback, the switch fails.Ensure that you call this method after open .To ensure normal playback, pay attention to the following when calling this method:Do not call this method when playback is paused.Do not call the seek method during switching.Before switching the media resource, make sure that the playback position does not exceed the total duration of the media resource to be switched.
453
+ *
454
+ * You can call this method to switch the media resource to be played according to the current network status. For example: When the network is poor, the media resource to be played is switched to a media resource address with a lower bitrate. When the network is good, the media resource to be played is switched to a media resource address with a higher bitrate. After calling this method, if you receive the PlayerEventSwitchComplete event in the onPlayerEvent callback, the switch is successful; If you receive the PlayerEventSwitchError event in the onPlayerEvent callback, the switch fails. Ensure that you call this method after open . To ensure normal playback, pay attention to the following when calling this method: Do not call this method when playback is paused. Do not call the seek method during switching. Before switching the media resource, make sure that the playback position does not exceed the total duration of the media resource to be switched.
440
455
  *
441
456
  * @param src The URL of the media resource.
442
457
  * @param syncPts Whether to synchronize the playback position (ms) before and after the switch:true: Synchronize the playback position before and after the switch.false: (Default) Do not synchronize the playback position before and after the switch.Make sure to set this parameter as false if you need to play live streams, or the switch fails. If you need to play on-demand streams, you can set the value of this parameter according to your scenarios.
443
458
  *
444
459
  * @returns
445
- * 0: Success.< 0: Failure.
460
+ * 0: Success. < 0: Failure.
446
461
  */
447
462
  abstract switchSrc(src: string, syncPts?: boolean): number;
448
463
 
449
464
  /**
450
465
  * Preloads a media resource.
451
- * You can call this method to preload a media resource into the playlist. If you need to preload multiple media resources, you can call this method multiple times.After calling this method, if you receive the PlayerPreloadEventComplete event in the onPreloadEvent callback, the preload is successful; If you receive the PlayerPreloadEventError event in the onPreloadEvent callback, the preload fails.If the preload is successful and you want to play the media resource, call playPreloadedSrc ; if you want to clear the playlist, call stop .Agora does not support preloading duplicate media resources to the playlist. However, you can preload the media resources that are being played to the playlist again.
466
+ *
467
+ * You can call this method to preload a media resource into the playlist. If you need to preload multiple media resources, you can call this method multiple times. After calling this method, if you receive the PlayerPreloadEventComplete event in the onPreloadEvent callback, the preload is successful; If you receive the PlayerPreloadEventError event in the onPreloadEvent callback, the preload fails. If the preload is successful and you want to play the media resource, call playPreloadedSrc ; if you want to clear the playlist, call stop . Agora does not support preloading duplicate media resources to the playlist. However, you can preload the media resources that are being played to the playlist again.
452
468
  *
453
469
  * @param src The URL of the media resource.
454
470
  * @param startPos The starting position (ms) for playing after the media resource is preloaded to the playlist. When preloading a live stream, set this parameter to 0.
455
471
  *
456
472
  * @returns
457
- * 0: Success.< 0: Failure.
473
+ * 0: Success. < 0: Failure.
458
474
  */
459
475
  abstract preloadSrc(src: string, startPos: number): number;
460
476
 
461
477
  /**
462
478
  * Plays preloaded media resources.
463
- * After calling the preloadSrc method to preload the media resource into the playlist, you can call this method to play the preloaded media resource. After calling this method, if you receive the onPlayerSourceStateChanged callback which reports the PlayerStatePlaying state, the playback is successful.If you want to change the preloaded media resource to be played, you can call this method again and specify the URL of the new media resource that you want to preload. If you want to replay the media resource, you need to call preloadSrc to preload the media resource to the playlist again before playing. If you want to clear the playlist, call the stop method.If you call this method when playback is paused, this method does not take effect until playback is resumed.
479
+ *
480
+ * After calling the preloadSrc method to preload the media resource into the playlist, you can call this method to play the preloaded media resource. After calling this method, if you receive the onPlayerSourceStateChanged callback which reports the PlayerStatePlaying state, the playback is successful. If you want to change the preloaded media resource to be played, you can call this method again and specify the URL of the new media resource that you want to preload. If you want to replay the media resource, you need to call preloadSrc to preload the media resource to the playlist again before playing. If you want to clear the playlist, call the stop method. If you call this method when playback is paused, this method does not take effect until playback is resumed.
464
481
  *
465
482
  * @param src The URL of the media resource in the playlist must be consistent with the src set by the preloadSrc method; otherwise, the media resource cannot be played.
466
483
  *
467
484
  * @returns
468
- * 0: Success.< 0: Failure.
485
+ * 0: Success. < 0: Failure.
469
486
  */
470
487
  abstract playPreloadedSrc(src: string): number;
471
488
 
472
489
  /**
473
490
  * Unloads media resources that are preloaded.
491
+ *
474
492
  * This method cannot release the media resource being played.
475
493
  *
476
494
  * @param src The URL of the media resource.
477
495
  *
478
496
  * @returns
479
- * 0: Success.< 0: Failure.
497
+ * 0: Success. < 0: Failure.
480
498
  */
481
499
  abstract unloadSrc(src: string): number;
482
500
 
483
501
  /**
484
502
  * Enables or disables the spatial audio effect for the media player.
485
- * After successfully setting the spatial audio effect parameters of the media player, the SDK enables the spatial audio effect for the media player, and the local user can hear the media resources with a sense of space.If you need to disable the spatial audio effect for the media player, set the params parameter to null.
503
+ *
504
+ * After successfully setting the spatial audio effect parameters of the media player, the SDK enables the spatial audio effect for the media player, and the local user can hear the media resources with a sense of space. If you need to disable the spatial audio effect for the media player, set the params parameter to null.
486
505
  *
487
506
  * @returns
488
- * 0: Success.< 0: Failure.
507
+ * 0: Success. < 0: Failure.
489
508
  */
490
509
  abstract setSpatialAudioParams(params: SpatialAudioParams): number;
491
510
 
@@ -501,35 +520,41 @@ export abstract class IMediaPlayer {
501
520
  export abstract class IMediaPlayerCacheManager {
502
521
  /**
503
522
  * Deletes all cached media files in the media player.
523
+ *
504
524
  * The cached media file currently being played will not be deleted.
505
525
  *
506
526
  * @returns
507
- * 0: Success.< 0: Failure. See MediaPlayerError .
527
+ * 0: Success. < 0: Failure. See MediaPlayerError .
508
528
  */
509
529
  abstract removeAllCaches(): number;
510
530
 
511
531
  /**
512
532
  * Deletes a cached media file that is the least recently used.
513
- * You can call this method to delete a cached media file when the storage space for the cached files is about to reach its limit. After you call this method, the SDK deletes the cached media file that is least used.The cached media file currently being played will not be deleted.
533
+ *
534
+ * You can call this method to delete a cached media file when the storage space for the cached files is about to reach its limit. After you call this method, the SDK deletes the cached media file that is least used. The cached media file currently being played will not be deleted.
514
535
  *
515
536
  * @returns
516
- * 0: Success.< 0: Failure. See MediaPlayerError .
537
+ * 0: Success.
538
+ * < 0: Failure. See MediaPlayerError .
517
539
  */
518
540
  abstract removeOldCache(): number;
519
541
 
520
542
  /**
521
543
  * Deletes a cached media file.
544
+ *
522
545
  * The cached media file currently being played will not be deleted.
523
546
  *
524
547
  * @param uri The URI (Uniform Resource Identifier) of the media file to be deleted.
525
548
  *
526
549
  * @returns
527
- * 0: Success.< 0: Failure. See MediaPlayerError .
550
+ * 0: Success.
551
+ * < 0: Failure. See MediaPlayerError .
528
552
  */
529
553
  abstract removeCacheByUri(uri: string): number;
530
554
 
531
555
  /**
532
556
  * Sets the storage path for the media files that you want to cache.
557
+ *
533
558
  * Make sure IRtcEngine is initialized before you call this method.
534
559
  *
535
560
  * @param path The absolute path of the media files to be cached. Ensure that the directory for the media files exists and is writable.
@@ -546,7 +571,8 @@ export abstract class IMediaPlayerCacheManager {
546
571
  * @param count The maximum number of media files that can be cached. The default value is 1,000.
547
572
  *
548
573
  * @returns
549
- * 0: Success.< 0: Failure. See MediaPlayerError .
574
+ * 0: Success.
575
+ * < 0: Failure. See MediaPlayerError .
550
576
  */
551
577
  abstract setMaxCacheFileCount(count: number): number;
552
578
 
@@ -563,6 +589,7 @@ export abstract class IMediaPlayerCacheManager {
563
589
 
564
590
  /**
565
591
  * Sets whether to delete cached media files automatically.
592
+ *
566
593
  * If you enable this function to remove cached media files automatically, when the cached media files exceed either the number or size limit you set, the SDK automatically deletes the least recently used cache file.
567
594
  *
568
595
  * @param enable Whether to enable the SDK to delete cached media files automatically:true: Delete cached media files automatically.false: (Default) Do not delete cached media files automatically.
@@ -575,30 +602,33 @@ export abstract class IMediaPlayerCacheManager {
575
602
 
576
603
  /**
577
604
  * Gets the storage path of the cached media files.
605
+ *
578
606
  * If you have not called the setCacheDir method to set the storage path for the media files to be cached before calling this method, you get the default storage path used by the SDK.
579
607
  *
580
608
  * @param length An input parameter; the maximum length of the cache file storage path string.
581
609
  *
582
610
  * @returns
583
- * The call succeeds, and the SDK returns the storage path of the cached media files.< 0: Failure. See MediaPlayerError .
611
+ * The call succeeds, and the SDK returns the storage path of the cached media files. < 0: Failure. See MediaPlayerError .
584
612
  */
585
613
  abstract getCacheDir(length: number): string;
586
614
 
587
615
  /**
588
616
  * Gets the maximum number of media files that can be cached.
617
+ *
589
618
  * By default, the maximum number of media files that can be cached is 1,000.
590
619
  *
591
620
  * @returns
592
- * > 0: The call succeeds and returns the maximum number of media files that can be cached.< 0: Failure. See MediaPlayerError .
621
+ * > 0: The call succeeds and returns the maximum number of media files that can be cached. < 0: Failure. See MediaPlayerError .
593
622
  */
594
623
  abstract getMaxCacheFileCount(): number;
595
624
 
596
625
  /**
597
626
  * Gets the maximum size of the aggregate storage space for cached media files.
627
+ *
598
628
  * By default, the maximum size of the aggregate storage space for cached media files is 1 GB. You can call the setMaxCacheFileSize method to set the limit according to your scenarios.
599
629
  *
600
630
  * @returns
601
- * > 0: The call succeeds and returns the maximum size (in bytes) of the aggregate storage space for cached media files.< 0: Failure. See MediaPlayerError .
631
+ * > 0: The call succeeds and returns the maximum size (in bytes) of the aggregate storage space for cached media files. < 0: Failure. See MediaPlayerError .
602
632
  */
603
633
  abstract getMaxCacheFileSize(): number;
604
634
 
@@ -606,7 +636,7 @@ export abstract class IMediaPlayerCacheManager {
606
636
  * Gets the number of media files that are cached.
607
637
  *
608
638
  * @returns
609
- * ≥ 0: The call succeeds and returns the number of media files that are cached.< 0: Failure. See MediaPlayerError .
639
+ * ≥ 0: The call succeeds and returns the number of media files that are cached. < 0: Failure. See MediaPlayerError .
610
640
  */
611
641
  abstract getCacheFileCount(): number;
612
642
  }
@@ -617,9 +647,10 @@ export abstract class IMediaPlayerCacheManager {
617
647
  export interface IMediaPlayerVideoFrameObserver {
618
648
  /**
619
649
  * Occurs each time the player receives a video frame.
650
+ *
620
651
  * After registering the video frame observer, the callback occurs every time the player receives a video frame, reporting the detailed information of the video frame.
621
652
  *
622
- * @param frame Video frame information. See VideoFrame .
653
+ * @param frame Video frame information. See VideoFrame.
623
654
  */
624
655
  onFrame?(frame: VideoFrame): void;
625
656
  }
@@ -14,10 +14,11 @@ import {
14
14
  export interface IMediaPlayerSourceObserver {
15
15
  /**
16
16
  * Reports the changes of playback state.
17
+ *
17
18
  * When the state of the media player changes, the SDK triggers this callback to report the current playback state.
18
19
  *
19
- * @param state The playback state. See MediaPlayerState .
20
- * @param ec The error code. See MediaPlayerError .
20
+ * @param state The playback state. See MediaPlayerState.
21
+ * @param ec The error code. See MediaPlayerError.
21
22
  */
22
23
  onPlayerSourceStateChanged?(
23
24
  state: MediaPlayerState,
@@ -26,6 +27,7 @@ export interface IMediaPlayerSourceObserver {
26
27
 
27
28
  /**
28
29
  * Reports current playback progress.
30
+ *
29
31
  * When playing media files, the SDK triggers this callback every two second to report current playback progress.
30
32
  *
31
33
  * @param position The playback position (ms) of media files.
@@ -34,9 +36,10 @@ export interface IMediaPlayerSourceObserver {
34
36
 
35
37
  /**
36
38
  * Reports the player events.
39
+ *
37
40
  * After calling the seek method, the SDK triggers the callback to report the results of the seek operation.
38
41
  *
39
- * @param eventCode The player events. See MediaPlayerEvent .
42
+ * @param eventCode The player events. See MediaPlayerEvent.
40
43
  * @param elapsedTime The time (ms) when the event occurs.
41
44
  * @param message Information about the event.
42
45
  */
@@ -48,6 +51,7 @@ export interface IMediaPlayerSourceObserver {
48
51
 
49
52
  /**
50
53
  * Occurs when the media metadata is received.
54
+ *
51
55
  * The callback occurs when the player receives the media metadata and reports the detailed information of the media metadata.
52
56
  *
53
57
  * @param data The detailed data of the media metadata.
@@ -57,7 +61,8 @@ export interface IMediaPlayerSourceObserver {
57
61
 
58
62
  /**
59
63
  * Reports the playback duration that the buffered data can support.
60
- * When playing online media resources, the SDK triggers this callback every two seconds to report the playback duration that the currently buffered data can support.When the playback duration supported by the buffered data is less than the threshold (0 by default), the SDK returns PlayerEventBufferLow.When the playback duration supported by the buffered data is greater than the threshold (0 by default), the SDK returns PlayerEventBufferRecover.
64
+ *
65
+ * When playing online media resources, the SDK triggers this callback every two seconds to report the playback duration that the currently buffered data can support. When the playback duration supported by the buffered data is less than the threshold (0 by default), the SDK returns PlayerEventBufferLow . When the playback duration supported by the buffered data is greater than the threshold (0 by default), the SDK returns PlayerEventBufferRecover .
61
66
  *
62
67
  * @param playCachedBuffer The playback duration (ms) that the buffered data can support.
63
68
  */
@@ -67,7 +72,7 @@ export interface IMediaPlayerSourceObserver {
67
72
  * Reports the events of preloaded media resources.
68
73
  *
69
74
  * @param src The URL of the media resource.
70
- * @param event Events that occur when media resources are preloaded. See PlayerPreloadEvent .
75
+ * @param event Events that occur when media resources are preloaded. See PlayerPreloadEvent.
71
76
  */
72
77
  onPreloadEvent?(src: string, event: PlayerPreloadEvent): void;
73
78
 
@@ -84,21 +89,23 @@ export interface IMediaPlayerSourceObserver {
84
89
  /**
85
90
  * Occurs when the video bitrate of the media resource changes.
86
91
  *
87
- * @param from Information about the video bitrate of the media resource being played. See SrcInfo .
88
- * @param to Information about the changed video bitrate of media resource being played. See SrcInfo .
92
+ * @param from Information about the video bitrate of the media resource being played. See SrcInfo.
93
+ * @param to Information about the changed video bitrate of media resource being played. See SrcInfo.
89
94
  */
90
95
  onPlayerSrcInfoChanged?(from: SrcInfo, to: SrcInfo): void;
91
96
 
92
97
  /**
93
98
  * Occurs when information related to the media player changes.
99
+ *
94
100
  * When the information about the media player changes, the SDK triggers this callback. You can use this callback for troubleshooting.
95
101
  *
96
- * @param info Information related to the media player. See PlayerUpdatedInfo .
102
+ * @param info Information related to the media player. See PlayerUpdatedInfo.
97
103
  */
98
104
  onPlayerInfoUpdated?(info: PlayerUpdatedInfo): void;
99
105
 
100
106
  /**
101
107
  * Reports the volume of the media player.
108
+ *
102
109
  * The SDK triggers this callback every 200 milliseconds to report the current volume of the media player.
103
110
  *
104
111
  * @param volume The volume of the media player. The value ranges from 0 to 255.