• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# avplayer_base.h
2<!--Kit: Media Kit-->
3<!--Subsystem: Multimedia-->
4<!--Owner: @xushubo; @chennotfound-->
5<!--Designer: @dongyu_dy-->
6<!--Tester: @xchaosioda-->
7<!--Adviser: @zengyawen-->
8
9## Overview
10
11The file declares the structs and enums of the AVPlayer.
12
13**File to include**: <multimedia/player_framework/avplayer_base.h>
14
15**Library**: libavplayer.so
16
17**System capability**: SystemCapability.Multimedia.Media.AVPlayer
18
19**Since**: 11
20
21**Related module**: [AVPlayer](capi-avplayer.md)
22
23## Summary
24
25### Structs
26
27| Name| typedef Keyword| Description|
28| -- | -- | -- |
29| [AVPlayerCallback](capi-avplayer-avplayercallback.md) | AVPlayerCallback | Contains the set of the [OH_AVPlayerOnInfo](#oh_avplayeroninfo) and **OH_AVPlayerOnInfo** callback function pointers. To ensure the normal running of OH_AVPlayer, you must register this struct with the OH_AVPlayer instance and process the information reported by the callback functions.|
30| [OH_AVPlayer](capi-avplayer-oh-avplayer.md) | OH_AVPlayer | Describes an initialized AVPlayer.|
31
32### Enums
33
34| Name| typedef Keyword| Description|
35| -- | -- | -- |
36| [AVPlayerState](#avplayerstate) | AVPlayerState | Enumerates the AVPlayer states.|
37| [AVPlayerSeekMode](#avplayerseekmode) | AVPlayerSeekMode | Enumerates the seek modes.|
38| [AVPlaybackSpeed](#avplaybackspeed) | AVPlaybackSpeed | Enumerates the playback speeds of the AVPlayer.|
39| [AVPlayerOnInfoType](#avplayeroninfotype) | AVPlayerOnInfoType | Enumerates the types of messages received by the AVPlayer.<br>The enum can be used in [OH_AVPlayerOnInfoCallback](#oh_avplayeroninfocallback) and [OH_AVPlayerOnInfo](#oh_avplayeroninfo) (deprecated) to indicate the type of information received by the AVPlayer.|
40| [AVPlayerBufferingType](#avplayerbufferingtype) | AVPlayerBufferingType | Enumerates the types of buffer messages of the AVPlayer.|
41
42### Functions
43
44| Name| typedef Keyword| Description|
45| -- | -- | -- |
46| [typedef void (\*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, int32_t extra)](#oh_avplayeroninfo) | OH_AVPlayerOnInfo | Called when the AVPlayer receives a message.|
47| [typedef void (\*OH_AVPlayerOnInfoCallback)(OH_AVPlayer \*player, AVPlayerOnInfoType type, OH_AVFormat* infoBody, void *userData)](#oh_avplayeroninfocallback) | OH_AVPlayerOnInfoCallback | Called when the AVPlayer receives a message. If this callback is successfully set, the [OH_AVPlayerOnInfo](#oh_avplayeroninfo) function will not be invoked.|
48| [typedef void (\*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg)](#oh_avplayeronerror) | OH_AVPlayerOnError | Called when an error occurs in the AVPlayer. This type is available in API version 9 or later.|
49| [typedef void (\*OH_AVPlayerOnErrorCallback)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg, void *userData)](#oh_avplayeronerrorcallback) | OH_AVPlayerOnErrorCallback | Called when an error occurs in the AVPlayer. If this callback is successfully set, the [OH_AVPlayerOnError](#oh_avplayeronerror) function will not be invoked.|
50
51### Variables
52
53| Name| Description|
54| -- | -- |
55| const char * OH_PLAYER_STATE | Pointer to the key for obtaining the AVPlayer state. The value is of the int32_t type.<br>**Since**: 12|
56| const char * OH_PLAYER_STATE_CHANGE_REASON | Pointer to the key for obtaining the AVPlayer state change reason. The value is of the int32_t type.<br>The value **1** means that the change is triggered by user operations, and **2** means that the change is triggered by the system.<br>**Since**: 12|
57| const char * OH_PLAYER_VOLUME | Pointer to the key for obtaining the volume. The value type is float.<br>**Since**: 12|
58| const char * OH_PLAYER_BITRATE_ARRAY | Pointer to the key for obtaining the bit rate array. The value is of the uint8_t byte array type. When this key is used to obtain information, you need to:<br>Use a pointer variable of the uint8_t type to store the bit rate list and use a variable of the size_t type to store the byte array length.<br>Then it allocates several storage spaces of the uint32_t type to receive the bit rate integer of the uint32_t type, which is converted from the uint8_t byte array.<br>For details, see the [OH_AVPlayerOnInfoCallback](#oh_avplayeroninfocallback) function described in the corresponding [development guide](../../media/media/using-ndk-avplayer-for-playback.md).<br>**Since**: 12|
59| const char * OH_PLAYER_AUDIO_INTERRUPT_TYPE | Pointer to the key for obtaining the audio interruption type. The value is of the int32_t type.<br>**Since**: 12|
60| const char * OH_PLAYER_AUDIO_INTERRUPT_FORCE | Pointer to the key for obtaining the FORCE type of audio interruption. The value is of the int32_t type.<br>**Since**: 12|
61| const char * OH_PLAYER_AUDIO_INTERRUPT_HINT | Pointer to the key for obtaining the HINT type of audio interruption. The value is of the int32_t type.<br>**Since**: 12|
62| const char * OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON | Pointer to the key for obtaining the audio device change reason. The value is of the int32_t type.<br>**Since**: 12|
63| const char * OH_PLAYER_BUFFERING_TYPE | Pointer to the key for obtaining the type of the buffer update message. The value type is [AVPlayerBufferingType](capi-avplayer-base-h.md#avplayerbufferingtype).<br>When this key is used to obtain information, you must use a variable of the int32_t type to save the result and then convert the result to a value of AVPlayerBufferingType.<br>**Since**: 12|
64| const char * OH_PLAYER_BUFFERING_VALUE | Pointer to the key for obtaining the value of the buffer update message. The value is of the int32_t type. For details, see [AVPlayerBufferingType](capi-avplayer-base-h.md#avplayerbufferingtype).<br>This parameter is valid only when the buffer update message type is **AVPLAYER_BUFFERING_PERCENT** or **AVPLAYER_BUFFERING_CACHED_DURATION**.<br>**Since**: 12|
65| const char * OH_PLAYER_SEEK_POSITION | Pointer to the key for obtaining the playback progress after the seek operation. The value is of the int32_t type.<br>**Since**: 12|
66| const char * OH_PLAYER_PLAYBACK_SPEED | Pointer to the key for obtaining the playback speed. The value type is [AVPlaybackSpeed](capi-avplayer-base-h.md#avplaybackspeed).<br>When this key is used to obtain information, you must use a variable of the int32_t type to save the result and then convert the result to a value of AVPlaybackSpeed.<br>**Since**: 12|
67| const char * OH_PLAYER_PLAYBACK_RATE | Pointer to the key for obtaining the playback rate. The value is a floating-point number.<br>**Since**: 20|
68| const char * OH_PLAYER_BITRATE | Pointer to the key for obtaining the bit rate. The value is of the uint32_t type.<br>**Since**: 12|
69| const char * OH_PLAYER_CURRENT_POSITION | Pointer to the key for obtaining the playback progress information. The value is of the int32_t type.<br>**Since**: 12|
70| const char * OH_PLAYER_DURATION | Pointer to the key for obtaining the media asset duration. The value type is int64_t.<br>**Since**: 12|
71| const char * OH_PLAYER_VIDEO_WIDTH | Pointer to the key for obtaining the video width. The value is of the int32_t type.<br>**Since**: 12|
72| const char * OH_PLAYER_VIDEO_HEIGHT | Pointer to the key for obtaining the video height. The value is of the int32_t type.<br>**Since**: 12|
73| const char * OH_PLAYER_MESSAGE_TYPE | Pointer to the key for obtaining the type of message received by the AVPlayer. The value is of the int32_t type.<br>The value **1** means that the video frame starts to be rendered.<br>**Since**: 12|
74| const char * OH_PLAYER_IS_LIVE_STREAM | Pointer to the key for checking whether a media asset is live streaming. The value is of the int32_t type.<br>The value **1** means live streaming.<br>**Since**: 12|
75
76## Enum Description
77
78### AVPlayerState
79
80```
81enum AVPlayerState
82```
83
84**Description**
85
86Enumerates the AVPlayer states.
87
88**System capability**: SystemCapability.Multimedia.Media.AVPlayer
89
90**Since**: 11
91
92| Enum Item| Description|
93| -- | -- |
94| AV_IDLE = 0 | Idle.|
95| AV_INITIALIZED = 1 | Initialized.|
96| AV_PREPARED = 2 | Ready.|
97| AV_PLAYING = 3 | Playing.|
98| AV_PAUSED = 4 | Paused.|
99| AV_STOPPED = 5 | Stopped.|
100| AV_COMPLETED = 6 | Completed.|
101| AV_RELEASED = 7 | Released.|
102| AV_ERROR = 8 | Error.|
103
104### AVPlayerSeekMode
105
106```
107enum AVPlayerSeekMode
108```
109
110**Description**
111
112Enumerates the seek modes.
113
114**System capability**: SystemCapability.Multimedia.Media.AVPlayer
115
116**Since**: 11
117
118| Enum Item| Description|
119| -- | -- |
120| AV_SEEK_NEXT_SYNC = 0 | Seeks to the next key frame at the specified position.|
121| AV_SEEK_PREVIOUS_SYNC | Seeks to the previous key frame at the specified position.|
122| AV_SEEK_CLOSEST = 2 | Seeks to the frame closest to the specified position.<br>**Since**: 12|
123
124### AVPlaybackSpeed
125
126```
127enum AVPlaybackSpeed
128```
129
130**Description**
131
132Enumerates the playback speeds of the AVPlayer.
133
134**System capability**: SystemCapability.Multimedia.Media.AVPlayer
135
136**Since**: 11
137
138| Enum Item| Description|
139| -- | -- |
140| AV_SPEED_FORWARD_0_75_X | Plays the video at 0.75 times the normal speed.|
141| AV_SPEED_FORWARD_1_00_X | Plays the video at the normal speed.|
142| AV_SPEED_FORWARD_1_25_X | Plays the video at 1.25 times the normal speed.|
143| AV_SPEED_FORWARD_1_75_X | Plays the video at 1.75 times the normal speed.|
144| AV_SPEED_FORWARD_2_00_X | Plays the video at 2.0 times the normal speed.|
145| AV_SPEED_FORWARD_0_50_X | Plays the video at 0.5 times the normal speed.<br>**Since**: 12|
146| AV_SPEED_FORWARD_1_50_X | Plays the video at 1.5 times the normal speed.<br>**Since**: 12|
147| AV_SPEED_FORWARD_3_00_X | Plays the video at 3.0 times the normal speed.<br>**Since**: 13|
148| AV_SPEED_FORWARD_0_25_X | Plays the video at 0.25 times the normal speed.<br>**Since**: 13|
149| AV_SPEED_FORWARD_0_125_X | Plays the video at 0.125 times the normal speed.<br>**Since**: 13|
150
151### AVPlayerOnInfoType
152
153```
154enum AVPlayerOnInfoType
155```
156
157**Description**
158
159Enumerates the types of messages received by the AVPlayer.<br>The enum can be used in **OH_AVPlayerOnInfoCallback** and **OH_AVPlayerOnInfo** (deprecated) to indicate the type of information received by the AVPlayer.<br>Since API version 12, you are advised to use [OH_AVPlayerOnInfoCallback](capi-avplayer-base-h.md#oh_avplayeroninfocallback) instead. Different information (**infoBody**) can be obtained for different **OnInfo** types. **infoBody** contains the key-value pairs. For details, see the following enumerated value table.<br>If you are using API version 11 for development, use **OH_AVPlayerOnInfo (deprecated)**. For details about the mappings used in this deprecated API, see [OH_AVPlayerOnInfo](capi-avplayer-base-h.md#oh_avplayeroninfo).
160
161**System capability**: SystemCapability.Multimedia.Media.AVPlayer
162
163**Since**: 11
164
165| Enum Item| Description|
166| -- | -- |
167| AV_INFO_TYPE_SEEKDONE = 0 | Message returned when seeking to a playback position is complete.<br>If **key** is set to **OH_PLAYER_SEEK_POSITION**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value.|
168| AV_INFO_TYPE_SPEEDDONE = 1 | Message returned when the playback speed setting is complete.<br>If **key** is set to **OH_PLAYER_PLAYBACK_SPEED**, the value is an enumerated value of [AVPlaybackSpeed](capi-avplayer-base-h.md#avplaybackspeed). The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value and forcibly converts the value to an enumerated value of [AVPlaybackSpeed](capi-avplayer-base-h.md#avplaybackspeed).|
169| AV_INFO_TYPE_BITRATEDONE = 2 | Message returned when the bit rate setting is complete.<br>If **key** is set to **OH_PLAYER_BITRATE**, the value type is uint32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value and forcibly converts the value to the uint32_t type.|
170| AV_INFO_TYPE_EOS = 3 | Message returned when the playback is complete.|
171| AV_INFO_TYPE_STATE_CHANGE = 4 | Message returned when the AVPlayer state changes.<br>If **key** is set to **OH_PLAYER_STATE**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value and forcibly converts the value to an enumerated value of [AVPlayerState](capi-avplayer-base-h.md#avplayerstate).<br>If **key** is set to **OH_PLAYER_STATE_CHANGE_REASON**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value. The value **1** means that the change is triggered by user operations, and **2** means that the change is triggered by the system.|
172| AV_INFO_TYPE_POSITION_UPDATE = 5 | Message returned when the playback position changes.<br>If **key** is set to **OH_PLAYER_CURRENT_POSITION**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value.|
173| AV_INFO_TYPE_MESSAGE = 6 | Message returned when video rendering starts.<br>If **key** is set to **OH_PLAYER_MESSAGE_TYPE**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value. The value **1** means that video rendering starts.|
174| AV_INFO_TYPE_VOLUME_CHANGE = 7 | Message returned when the playback volume changes.<br>If **key** is set to **OH_PLAYER_VOLUME**, the value type is float. The system uses float to transfer the value, and the application uses float to obtain the value. The value range is [0.0, 1.0].|
175| AV_INFO_TYPE_RESOLUTION_CHANGE = 8 | Message returned when the video size is obtained for the first time or the video size is updated.<br>If **key** is set to **OH_PLAYER_VIDEO_WIDTH** or **OH_PLAYER_VIDEO_HEIGHT**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value.|
176| AV_INFO_TYPE_BUFFERING_UPDATE = 9 | Message returned when multi-queue buffering changes.<br>If **key** is set to **OH_PLAYER_BUFFERING_TYPE**, the value is an enumerated value of [AVPlayerBufferingType](capi-avplayer-base-h.md#avplayerbufferingtype). The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value and forcibly converts the value to an enumerated value of [AVPlayerBufferingType](capi-avplayer-base-h.md#avplayerbufferingtype).<br>If **key** is set to **OH_PLAYER_BUFFERING_VALUE**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value.<br>This value is valid when the buffer update message type is **AVPLAYER_BUFFERING_PERCENT** or **AVPLAYER_BUFFERING_CACHED_DURATION**, which indicate the percentage of the buffer progress and the duration that the cached data can play, respectively.|
177| AV_INFO_TYPE_BITRATE_COLLECT = 10 | Message returned to report the HLS video bit rates.<br>If **key** is set to **OH_PLAYER_BITRATE_ARRAY**, the value type is uint8_t. The application uses a pointer variable of the uint8_t type to store the bit rate list and uses a variable of the size_t type to store the byte array length. Then it allocates several storage spaces of the uint32_t type to receive the bit rate integer of the uint32_t type, which is converted from the uint8_t byte array.|
178| AV_INFO_TYPE_INTERRUPT_EVENT = 11 | Message returned when the audio focus changes.<br>The value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value.<br>**key** can be set to any of the following values:<br>**OH_PLAYER_AUDIO_INTERRUPT_TYPE**: The value **1** means that the audio interruption event starts, and **2** means that the event ends.<br>**OH_PLAYER_AUDIO_INTERRUPT_FORCE**: The value **0** means forcible interruption (the system changes the audio playback status), and **1** means sharing interruption (the application changes the audio playback status).<br>**OH_PLAYER_AUDIO_INTERRUPT_HINT**: The value **0** (NONE) means no hint; **1** (RESUME) means that the audio playback is resumed; **2** (PAUSE) means that the audio playback is paused and loses focus; **3** (STOP) means that the audio playback is stopped; **4** (DUCK) means that the audio volume is reduced; **5** (UNDUCK) means that the audio volume is restored.|
179| AV_INFO_TYPE_DURATION_UPDATE = 12 | Message returned when the playback duration changes.<br>If **key** is set to **OH_PLAYER_DURATION**, the value type is int64_t. The system uses int64_t to transfer the value, and the application uses int64_t to obtain the value.|
180| AV_INFO_TYPE_IS_LIVE_STREAM = 13 | Message returned when live streams are played. If **key** is set to **OH_PLAYER_IS_LIVE_STREAM**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value. The value **0** means a non-live stream, and **1** means a live stream.|
181| AV_INFO_TYPE_TRACKCHANGE = 14 | Message returned when the track changes. **extra** is not defined in this scenario.|
182| AV_INFO_TYPE_TRACK_INFO_UPDATE = 15 | Message returned when the track information updates. **extra** is not defined in this scenario.|
183| AV_INFO_TYPE_SUBTITLE_UPDATE = 16 | Message returned when the subtitle information changes. **extra** is not defined in this scenario.|
184| AV_INFO_TYPE_AUDIO_OUTPUT_DEVICE_CHANGE = 17 | Message returned when the audio output device changes.<br>If **key** is set to **OH_PLAYER_AUDIO_DEVICE_CHANGE_REASON**, the value type is int32_t. The system uses int32_t to transfer the value, and the application uses int32_t to obtain the value.|
185| AV_INFO_TYPE_PLAYBACK_RATE_DONE = 18 | Message returned when the playback rate is applied.<br>If **key** is set to **OH_PLAYER_PLAYBACK_RATE**, the value type is float. The system uses float to transfer the value, and the application uses float to obtain the value.<br>**Since**: 20|
186
187### AVPlayerBufferingType
188
189```
190enum AVPlayerBufferingType
191```
192
193**Description**
194
195Enumerates the types of buffer messages of the AVPlayer.
196
197**System capability**: SystemCapability.Multimedia.Media.AVPlayer
198
199**Since**: 12
200
201| Enum Item| Description|
202| -- | -- |
203| AVPLAYER_BUFFERING_START = 1 | Buffering start message.|
204| AVPLAYER_BUFFERING_END | Buffering end message.|
205| AVPLAYER_BUFFERING_PERCENT | Buffer execution progress, in percentage. The value is an integer in the range [0, 100].|
206| AVPLAYER_BUFFERING_CACHED_DURATION | Duration that cached data can be played, in milliseconds.|
207
208
209## Function Description
210
211### OH_AVPlayerOnInfo()
212
213```
214typedef void (*OH_AVPlayerOnInfo)(OH_AVPlayer *player, AVPlayerOnInfoType type, int32_t extra)
215```
216
217**Description**
218
219Called when the AVPlayer receives a message.
220
221The following table lists the mappings between **type** and **extra** values.
222
223| Value of type| Value of extra|
224| -------- | -------- |
225| AV_INFO_TYPE_SEEKDONE | Message returned when seeking to a playback position is complete. **extra** indicates the position after the seek operation.|
226| AV_INFO_TYPE_SPEEDDONE | Message returned when the playback speed setting is complete. **extra** indicates the playback speed. For details about the available options, see [AVPlaybackSpeed](#avplaybackspeed).|
227| AV_INFO_TYPE_BITRATEDONE | Message returned when the bit rate setting is complete. **extra** indicates the bit rate.|
228| AV_INFO_TYPE_EOS | Message returned when the playback is complete.|
229| AV_INFO_TYPE_STATE_CHANGE | Message returned when the AVPlayer state changes. **extra** indicates the new state. For details about the available options, see [AVPlayerState](#avplayerstate).|
230| AV_INFO_TYPE_POSITION_UPDATE | Message returned when the playback position changes. **extra** indicates the current position.|
231| AV_INFO_TYPE_MESSAGE | Message returned when video rendering starts. **extra** indicates the first video frame rendered.|
232| AV_INFO_TYPE_VOLUME_CHANGE | Message returned when the playback volume changes. **extra** is not defined in this scenario.|
233| AV_INFO_TYPE_RESOLUTION_CHANGE | Message returned when the video size is obtained for the first time or the video size is updated. **extra** is not defined in this scenario.|
234| AV_INFO_TYPE_BUFFERING_UPDATE | Message returned when multi-queue buffering changes. **extra** indicates the video duration.|
235| AV_INFO_TYPE_BITRATE_COLLECT  | Message returned to report the HLS video bit rates. Each bit rate has been converted into a uint8_t byte array during the reporting. You need to forcibly convert the uint8_t byte array into a uint32_t integer array.  |
236| AV_INFO_TYPE_INTERRUPT_EVENT | Message returned when the audio focus changes. **extra** indicates the hints provided along with audio interruption. For details about the available options, see [OH_AudioInterrupt_Hint](../apis-audio-kit/capi-native-audiostream-base-h.md#oh_audiointerrupt_hint). The application can determine whether to perform further processing based on the hint.|
237| AV_INFO_TYPE_DURATION_UPDATE | Message returned when the playback duration changes. **extra** indicates the video duration.|
238| AV_INFO_TYPE_IS_LIVE_STREAM | Message returned when live streams are played. **extra** indicates whether the stream is a live stream. The value **0** means a non-live stream, and **1** means a live stream.|
239| AV_INFO_TYPE_TRACKCHANGE | Message returned when the track changes. **extra** is not defined in this scenario.|
240| AV_INFO_TYPE_TRACK_INFO_UPDATE |Message returned when the track information updates. **extra** is not defined in this scenario.|
241| AV_INFO_TYPE_SUBTITLE_UPDATE | Message returned when the subtitle information changes. **extra** is not defined in this scenario.|
242| AV_INFO_TYPE_AUDIO_OUTPUT_DEVICE_CHANGE | Message returned when the audio output device changes. **extra** indicates the device change reason. For details about the available options, see [OH_AudioStream_DeviceChangeReason](../apis-audio-kit/capi-native-audiostream-base-h.md#oh_audiostream_devicechangereason).|
243
244**System capability**: SystemCapability.Multimedia.Media.AVPlayer
245
246**Since**: 11
247
248**Deprecated from**: 12
249
250**Substitute**: [OH_AVPlayerOnInfoCallback](capi-avplayer-base-h.md#oh_avplayeroninfocallback)
251
252
253**Parameters**
254
255| Parameter| Description|
256| -- | -- |
257| [OH_AVPlayer](capi-avplayer-oh-avplayer.md) *player | Pointer to an OH_AVPlayer instance.|
258| [AVPlayerOnInfoType](capi-avplayer-base-h.md#avplayeroninfotype) type | Message type. For details about the available options, see [AVPlayerOnInfoType](capi-avplayer-base-h.md#avplayeroninfotype). For details about the mappings between **type** and **extra** values, see the function description.|
259|  int32_t extra | Other information, such as the start time and position of the media file to play.|
260
261### OH_AVPlayerOnInfoCallback()
262
263```
264typedef void (*OH_AVPlayerOnInfoCallback)(OH_AVPlayer *player, AVPlayerOnInfoType type, OH_AVFormat* infoBody,void *userData)
265```
266
267**Description**
268
269Called when the AVPlayer receives a message. If this callback is successfully set, the **OH_AVPlayerOnInfo** function will not be invoked.
270
271**System capability**: SystemCapability.Multimedia.Media.AVPlayer
272
273**Since**: 12
274
275
276**Parameters**
277
278| Parameter| Description|
279| -- | -- |
280| [OH_AVPlayer](capi-avplayer-oh-avplayer.md) *player | Pointer to an OH_AVPlayer instance.|
281| [AVPlayerOnInfoType](capi-avplayer-base-h.md#avplayeroninfotype) type | Message type. For details about the available options, see [AVPlayerOnInfoType](capi-avplayer-base-h.md#avplayeroninfotype).|
282| [OH_AVFormat](../apis-avcodec-kit/_core.md#oh_avformat)* infoBody | Pointer to the message. The pointer is valid only in this callback.|
283| void *userData | Pointer to the instance provided by the caller when setting the callback function.|
284
285### OH_AVPlayerOnError()
286
287```
288typedef void (*OH_AVPlayerOnError)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg)
289```
290
291**Description**
292
293Defines the callback when an error occurs in the AVPlayer. This type is available in API version 9 or later.
294
295**System capability**: SystemCapability.Multimedia.Media.AVPlayer
296
297**Since**: 11
298
299**Deprecated from**: 12
300
301**Substitute**: [OH_AVPlayerOnInfoCallback](capi-avplayer-base-h.md#oh_avplayeroninfocallback) and [OH_AVPlayerOnError](capi-avplayer-base-h.md#oh_avplayeronerror)
302
303
304**Parameters**
305
306| Parameter| Description|
307| -- | -- |
308| [OH_AVPlayer](capi-avplayer-oh-avplayer.md) *player | Pointer to an OH_AVPlayer instance.|
309|  int32_t errorCode | Error code.<br>**AV_ERR_NO_MEMORY**: No memory. The value is **1**.<br>**AV_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The value is **2**.<br>**AV_ERR_INVALID_VAL**: Invalid value. The value is **3**.<br>**AV_ERR_IO**: I/O error. The value is **4**.<br>**AV_ERR_TIMEOUT**: Timeout. The value is **5**.<br>**AV_ERR_UNKNOWN**: Unknown error. The value is **6**.<br>**AV_ERR_SERVICE_DIED**: The service is dead. The value is **7**.<br>**AV_ERR_INVALID_STATE**: The operation is not supported in the current state. The value is **8**.<br>**AV_ERR_UNSUPPORT**: The function is not supported. The value is **9**.<br>**AV_ERR_EXTEND_START**: Initial value for extended error codes. The value is **100**.|
310|  const char *errorMsg | Pointer to the error message.|
311
312### OH_AVPlayerOnErrorCallback()
313
314```
315typedef void (*OH_AVPlayerOnErrorCallback)(OH_AVPlayer *player, int32_t errorCode, const char *errorMsg,void *userData)
316```
317
318**Description**
319
320Called when an error occurs in the AVPlayer. If this callback is successfully set, the **OH_AVPlayerOnError** function will not be invoked.
321
322**System capability**: SystemCapability.Multimedia.Media.AVPlayer
323
324**Since**: 12
325
326
327**Parameters**
328
329| Parameter| Description|
330| -- | -- |
331| [OH_AVPlayer](capi-avplayer-oh-avplayer.md) *player | Pointer to an OH_AVPlayer instance.|
332|  int32_t errorCode | Error code.<br>**AV_ERR_NO_MEMORY**: No memory. The value is **1**.<br>**AV_ERR_OPERATE_NOT_PERMIT**: The operation is not allowed. The value is **2**.<br>**AV_ERR_INVALID_VAL**: Invalid value. The value is **3**.<br>**AV_ERR_IO**: I/O error. For API versions 12 and 13, the value is **4**. Starting from API version 14, it corresponds to more specific error codes ranging from 5411001 to 5411011.<br>**AV_ERR_TIMEOUT**: Timeout. The value is **5**.<br>**AV_ERR_UNKNOWN**: Unknown error. The value is **6**.<br>**AV_ERR_SERVICE_DIED**: The service is dead. The value is **7**.<br>**AV_ERR_INVALID_STATE**: The operation is not supported in the current state. The value is **8**.<br>**AV_ERR_UNSUPPORT**: The function is not supported. The value is **9**.<br>**AV_ERR_EXTEND_START**: Initial value for extended error codes. The value is **100**.|
333|  const char *errorMsg | Pointer to the error message.|
334| void *userData | Pointer to the user data passed in. The same data is returned.|
335