1# OHAVSession
2
3
4## Overview
5
6The OHAVSession module defines the C APIs of the playback control module.
7
8You can use OHAVSession to access AVSession as a provider. For details about the development guide and samples, see [AVSession Provider](../../media/avsession/using-ohavsession-developer.md).
9
10**System capability**: SystemCapability.Multimedia.AVSession.Core
11
12**Since**: 13
13
14
15## Summary
16
17
18### Files
19
20| Name| Description|
21| -------- | -------- |
22| [native_avmetadata.h](native__avmetadata_8h.md) | Declares the definitions of playback control metadata.|
23| [native_avsession.h](native__avsession_8h.md) | Declares the AVSession definition, which can be used to set metadata, playback state, and other information.|
24| [native_avsession_errors.h](native__avsession__errors_8h.md) | Declares the playback control error codes.|
25
26
27### Structs
28
29| Name| Description|
30| -------- | -------- |
31| struct  [AVSession_PlaybackPosition](_a_v_session___playback_position.md) | Describes the information related to the playback position.|
32
33
34### Types
35
36| Name| Description|
37| -------- | -------- |
38| typedef struct OH_AVMetadataBuilderStruct [OH_AVMetadataBuilder](#oh_avmetadatabuilder) | Defines a struct for the session metadata builder. The builder is used to construct session metadata.|
39| typedef struct OH_AVMetadataStruct [OH_AVMetadata](#oh_avmetadata) | Defines a struct for the session metadata. It is an AVMetadata instance set for a media asset.|
40| typedef struct [AVSession_PlaybackPosition](_a_v_session___playback_position.md) [AVSession_PlaybackPosition](#avsession_playbackposition) | Defines a struct for the information related to the playback position.|
41| typedef enum [AVSession_ControlCommand](#avsession_controlcommand) [AVSession_ControlCommand](#avsession_controlcommand) | Defines an enum for the playback control commands.|
42| typedef [AVSessionCallback_Result](#avsessioncallback_result)(\* [OH_AVSessionCallback_OnCommand](#oh_avsessioncallback_oncommand)) ([OH_AVSession](#oh_avsession) \*session, [AVSession_ControlCommand](#avsession_controlcommand) command, void \*userData) | Defines a callback for a common playback control command.|
43| typedef [AVSessionCallback_Result](#avsessioncallback_result)(\* [OH_AVSessionCallback_OnFastForward](#oh_avsessioncallback_onfastforward)) ([OH_AVSession](#oh_avsession) \*session, uint32_t seekTime, void \*userData) | Defines a callback for the fast-forward operation.|
44| typedef [AVSessionCallback_Result](#avsessioncallback_result)(\* [OH_AVSessionCallback_OnRewind](#oh_avsessioncallback_onrewind)) ([OH_AVSession](#oh_avsession) \*session, uint32_t seekTime, void \*userData) | Defines a callback for the rewind operation.|
45| typedef [AVSessionCallback_Result](#avsessioncallback_result)(\* [OH_AVSessionCallback_OnSeek](#oh_avsessioncallback_onseek)) ([OH_AVSession](#oh_avsession) \*session, uint64_t seekTime, void \*userData) | Defines a callback for the seek operation.|
46| typedef [AVSessionCallback_Result](#avsessioncallback_result)(\* [OH_AVSessionCallback_OnSetLoopMode](#oh_avsessioncallback_onsetloopmode)) ([OH_AVSession](#oh_avsession) \*session, [AVSession_LoopMode](#avsession_loopmode) curLoopMode, void \*userData) | Defines a callback for the operation of setting the loop mode.|
47| typedef [AVSessionCallback_Result](#avsessioncallback_result)(\* [OH_AVSessionCallback_OnToggleFavorite](#oh_avsessioncallback_ontogglefavorite)) ([OH_AVSession](#oh_avsession) \*session, const char \*assetId, void \*userData) | Defines a callback for the operation of favoriting a media asset.|
48| typedef struct [OH_AVSession](#oh_avsession) [OH_AVSession](#oh_avsession) | Defines a struct for the playback control session object.|
49
50
51### Enums
52
53| Name| Description|
54| -------- | -------- |
55| [AVMetadata_Result](#avmetadata_result) {<br>AVMETADATA_SUCCESS = 0,<br>AVMETADATA_ERROR_INVALID_PARAM = 1,<br>AVMETADATA_ERROR_NO_MEMORY = 2 } | Enumerates the error codes related to metadata operations.|
56| [AVMetadata_SkipIntervals](#avmetadata_skipintervals) {<br>SECONDS_10 = 10,<br>SECONDS_15 = 15,<br>SECONDS_30 = 30 } | Enumerates the fast-forward or rewind intervals supported by the media session.|
57| [AVMetadata_DisplayTag](#avmetadata_displaytag) { AVSESSION_DISPLAYTAG_AUDIO_VIVID = 1 } | Enumerates the display tags of the media asset. The display tag is a special type identifier of the media audio source.|
58| [AVSession_Type](#avsession_type) {<br>SESSION_TYPE_AUDIO = 0,<br>SESSION_TYPE_VIDEO = 1,<br>SESSION_TYPE_VOICE_CALL = 2,<br>SESSION_TYPE_VIDEO_CALL = 3 } | Enumerates the session types.|
59| [AVSession_PlaybackState](#avsession_playbackstate) {<br>PLAYBACK_STATE_INITIAL = 0,<br>PLAYBACK_STATE_PREPARING = 1,<br>PLAYBACK_STATE_PLAYING = 2,<br>PLAYBACK_STATE_PAUSED = 3,<br>PLAYBACK_STATE_FAST_FORWARDING = 4,<br>PLAYBACK_STATE_REWINDED = 5,<br>PLAYBACK_STATE_STOPPED = 6,<br>PLAYBACK_STATE_COMPLETED = 7,<br>PLAYBACK_STATE_RELEASED = 8,<br>PLAYBACK_STATE_ERROR = 9,<br>PLAYBACK_STATE_IDLE = 10,<br>PLAYBACK_STATE_BUFFERING = 11,<br>PLAYBACK_STATE_MAX = 12<br>} | Enumerates the media playback states.|
60| [AVSession_LoopMode](#avsession_loopmode) {<br>LOOP_MODE_SEQUENCE = 0,<br>LOOP_MODE_SINGLE = 1,<br>LOOP_MODE_LIST = 2,<br>LOOP_MODE_SHUFFLE = 3,<br>LOOP_MODE_CUSTOM = 4<br>} | Enumerates the loop modes of media playback.|
61| [AVSession_ControlCommand](#avsession_controlcommand) {<br>CONTROL_CMD_INVALID = -1,<br>CONTROL_CMD_PLAY = 0,<br>CONTROL_CMD_PAUSE = 1,<br>CONTROL_CMD_STOP = 2,<br>CONTROL_CMD_PLAY_NEXT = 3,<br>CONTROL_CMD_PLAY_PREVIOUS = 4<br>} | Enumerates the playback control commands.|
62| [AVSessionCallback_Result](#avsessioncallback_result) {<br>AVSESSION_CALLBACK_RESULT_SUCCESS = 0,<br>AVSESSION_CALLBACK_RESULT_FAILURE = -1 } | Enumerates the callback execution results.|
63| [AVSession_ErrCode](#avsession_errcode) {<br>AV_SESSION_ERR_SUCCESS = 0,<br>AV_SESSION_ERR_INVALID_PARAMETER = 401,<br>AV_SESSION_ERR_SERVICE_EXCEPTION = 6600101,<br>AV_SESSION_ERR_CODE_SESSION_NOT_EXIST = 6600102,<br>AV_SESSION_ERR_CODE_COMMAND_INVALID = 6600105,<br>AV_SESSION_ERR_CODE_SESSION_INACTIVE = 6600106,<br>AV_SESSION_ERR_CODE_MESSAGE_OVERLOAD = 6600107<br>} | Enumerates the playback control error codes.|
64
65
66### Functions
67
68| Name| Description|
69| -------- | -------- |
70| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_Create](#oh_avmetadatabuilder_create) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*\*builder) | Creates a metadata builder.|
71| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_Destroy](#oh_avmetadatabuilder_destroy) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder) | Destroys a metadata builder.|
72| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetAssetId](#oh_avmetadatabuilder_setassetid) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*assetId) | Sets the ID of the media asset.|
73| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetTitle](#oh_avmetadatabuilder_settitle) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*title) | Sets a title for the media asset.|
74| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetArtist](#oh_avmetadatabuilder_setartist) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*artist) | Sets an artist for the media asset.|
75| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetAuthor](#oh_avmetadatabuilder_setauthor) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*author) | Sets an author for the media asset.|
76| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetAlbum](#oh_avmetadatabuilder_setalbum) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*album) | Sets an album name for the media asset.|
77| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetWriter](#oh_avmetadatabuilder_setwriter) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*writer) | Sets a writer for the media asset.|
78| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetComposer](#oh_avmetadatabuilder_setcomposer) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*composer) | Sets a composer for the media asset.|
79| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetDuration](#oh_avmetadatabuilder_setduration) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, int64_t duration) | Sets the playback duration for the media asset.|
80| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetMediaImageUri](#oh_avmetadatabuilder_setmediaimageuri) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*mediaImageUri) | Sets an image for the media asset.|
81| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetSubtitle](#oh_avmetadatabuilder_setsubtitle) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*subtitle) | Sets a subtitle for the media asset.|
82| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetDescription](#oh_avmetadatabuilder_setdescription) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*description) | Sets a description for the media asset.|
83| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetLyric](#oh_avmetadatabuilder_setlyric) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, const char \*lyric) | Sets lyrics for the media asset.|
84| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetSkipIntervals](#oh_avmetadatabuilder_setskipintervals) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, [AVMetadata_SkipIntervals](#avmetadata_skipintervals) intervals) | Sets the skip intervals for the media asset.|
85| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_SetDisplayTags](#oh_avmetadatabuilder_setdisplaytags) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, int32_t tags) | Sets display tags for the media asset.|
86| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadataBuilder_GenerateAVMetadata](#oh_avmetadatabuilder_generateavmetadata) ([OH_AVMetadataBuilder](#oh_avmetadatabuilder) \*builder, [OH_AVMetadata](#oh_avmetadata) \*\*avMetadata) | Generates an **OH_AVMetadata** object.|
87| [AVMetadata_Result](#avmetadata_result) [OH_AVMetadata_Destroy](#oh_avmetadata_destroy) ([OH_AVMetadata](#oh_avmetadata) \*avMetadata) | Releases an **OH_AVMetadata** object.|
88| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_Create](#oh_avsession_create) ([AVSession_Type](#avsession_type) sessionType, const char \*sessionTag, const char \*bundleName, const char \*abilityName, [OH_AVSession](#oh_avsession) \*\*avsession) | Creates a session object.|
89| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_Destroy](#oh_avsession_destroy) ([OH_AVSession](#oh_avsession) \*avsession) | Destroys a session object.|
90| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_Activate](#oh_avsession_activate) ([OH_AVSession](#oh_avsession) \*avsession) | Activates a session.|
91| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_Deactivate](#oh_avsession_deactivate) ([OH_AVSession](#oh_avsession) \*avsession) | Deactivates a session.|
92| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_GetSessionType](#oh_avsession_getsessiontype) ([OH_AVSession](#oh_avsession) \*avsession, [AVSession_Type](#avsession_type) \*sessionType) | Obtains the session type.|
93| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_GetSessionId](#oh_avsession_getsessionid) ([OH_AVSession](#oh_avsession) \*avsession, const char \*\*sessionId) | Obtains the session ID.|
94| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_SetAVMetadata](#oh_avsession_setavmetadata) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVMetadata](#oh_avmetadata) \*avmetadata) | Sets media metadata.|
95| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_SetPlaybackState](#oh_avsession_setplaybackstate) ([OH_AVSession](#oh_avsession) \*avsession, [AVSession_PlaybackState](#avsession_playbackstate) playbackState) | Sets the playback state.|
96| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_SetPlaybackPosition](#oh_avsession_setplaybackposition) ([OH_AVSession](#oh_avsession) \*avsession, [AVSession_PlaybackPosition](_a_v_session___playback_position.md) \*playbackPosition) | Sets the playback position.|
97| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_SetFavorite](#oh_avsession_setfavorite) ([OH_AVSession](#oh_avsession) \*avsession, bool favorite) | Favorites or unfavorites the media asset.|
98| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_SetLoopMode](#oh_avsession_setloopmode) ([OH_AVSession](#oh_avsession) \*avsession, [AVSession_LoopMode](#avsession_loopmode) loopMode) | Sets a loop mode.|
99| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_RegisterCommandCallback](#oh_avsession_registercommandcallback) ([OH_AVSession](#oh_avsession) \*avsession, [AVSession_ControlCommand](#avsession_controlcommand) command, [OH_AVSessionCallback_OnCommand](#oh_avsessioncallback_oncommand) callback, void \*userData) | Registers a callback for a common playback control command.|
100| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_UnregisterCommandCallback](#oh_avsession_unregistercommandcallback) ([OH_AVSession](#oh_avsession) \*avsession, [AVSession_ControlCommand](#avsession_controlcommand) command, [OH_AVSessionCallback_OnCommand](#oh_avsessioncallback_oncommand) callback) | Unregisters the callback for a common playback control command.|
101| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_RegisterForwardCallback](#oh_avsession_registerforwardcallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnFastForward](#oh_avsessioncallback_onfastforward) callback, void \*userData) | Registers a callback for the fast-forward operation.|
102| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_UnregisterForwardCallback](#oh_avsession_unregisterforwardcallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnFastForward](#oh_avsessioncallback_onfastforward) callback) | Unregisters the callback for the fast-forward operation.|
103| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_RegisterRewindCallback](#oh_avsession_registerrewindcallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnRewind](#oh_avsessioncallback_onrewind) callback, void \*userData) | Registers a callback for the rewind operation.|
104| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_UnregisterRewindCallback](#oh_avsession_unregisterrewindcallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnRewind](#oh_avsessioncallback_onrewind) callback) | Unregisters the callback for the rewind operation.|
105| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_RegisterSeekCallback](#oh_avsession_registerseekcallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnSeek](#oh_avsessioncallback_onseek) callback, void \*userData) | Registers a callback for the seek operation.|
106| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_UnregisterSeekCallback](#oh_avsession_unregisterseekcallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnSeek](#oh_avsessioncallback_onseek) callback) | Unregisters the callback for the seek operation.|
107| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_RegisterSetLoopModeCallback](#oh_avsession_registersetloopmodecallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnSetLoopMode](#oh_avsessioncallback_onsetloopmode) callback, void \*userData) | Registers a callback for the operation of setting the loop mode.|
108| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_UnregisterSetLoopModeCallback](#oh_avsession_unregistersetloopmodecallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnSetLoopMode](#oh_avsessioncallback_onsetloopmode) callback) | Unregisters the callback for the operation of setting the loop mode.|
109| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_RegisterToggleFavoriteCallback](#oh_avsession_registertogglefavoritecallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnToggleFavorite](#oh_avsessioncallback_ontogglefavorite) callback, void \*userData) | Registers a callback for the operation of favoriting a media asset.|
110| [AVSession_ErrCode](#avsession_errcode) [OH_AVSession_UnregisterToggleFavoriteCallback](#oh_avsession_unregistertogglefavoritecallback) ([OH_AVSession](#oh_avsession) \*avsession, [OH_AVSessionCallback_OnToggleFavorite](#oh_avsessioncallback_ontogglefavorite) callback) | Unregisters the callback for the operation of favoriting a media asset.|
111
112
113## Type Description
114
115
116### AVSession_ControlCommand
117
118```
119typedef enum AVSession_ControlCommand AVSession_ControlCommand
120```
121
122**Description**
123
124Defines an enum for the playback control commands.
125
126**Since**: 13
127
128
129### AVSession_PlaybackPosition
130
131```
132typedef struct AVSession_PlaybackPosition AVSession_PlaybackPosition
133```
134
135**Description**
136
137Defines a struct for the information related to the playback position.
138
139**Since**: 13
140
141
142### OH_AVMetadata
143
144```
145typedef struct OH_AVMetadataStruct OH_AVMetadata
146```
147
148**Description**
149
150Defines a struct for the session metadata. It is an AVMetadata instance set for a media asset.
151
152**Since**: 13
153
154
155### OH_AVMetadataBuilder
156
157```
158typedef struct OH_AVMetadataBuilderStruct OH_AVMetadataBuilder
159```
160
161**Description**
162
163Defines a struct for the session metadata builder. The builder is used to construct session metadata.
164
165**Since**: 13
166
167
168### OH_AVSession
169
170```
171typedef struct OH_AVSession OH_AVSession
172```
173
174**Description**
175
176Defines a struct for the playback control session object.
177
178You can use **OH_AVSession_Create** to create such an object.
179
180**Since**: 13
181
182
183### OH_AVSessionCallback_OnCommand
184
185```
186typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnCommand)(OH_AVSession* session, AVSession_ControlCommand command, void* userData)
187```
188
189**Description**
190
191Defines a callback for a common playback control command.
192
193**Since**: 13
194
195
196### OH_AVSessionCallback_OnFastForward
197
198```
199typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnFastForward)(OH_AVSession* session, uint32_t seekTime, void* userData)
200```
201
202**Description**
203
204Defines a callback for the fast-forward operation.
205
206**Since**: 13
207
208
209### OH_AVSessionCallback_OnRewind
210
211```
212typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnRewind)(OH_AVSession* session, uint32_t seekTime, void* userData)
213```
214
215**Description**
216
217Defines a callback for the rewind operation.
218
219**Since**: 13
220
221
222### OH_AVSessionCallback_OnSeek
223
224```
225typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnSeek)(OH_AVSession* session, uint64_t seekTime, void* userData)
226```
227
228**Description**
229
230Defines a callback for the seek operation.
231
232**Since**: 13
233
234
235### OH_AVSessionCallback_OnSetLoopMode
236
237```
238typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnSetLoopMode)(OH_AVSession* session, AVSession_LoopMode curLoopMode, void* userData)
239```
240
241**Description**
242
243Defines a callback for the operation of setting the loop mode.
244
245**Since**: 13
246
247
248### OH_AVSessionCallback_OnToggleFavorite
249
250```
251typedef AVSessionCallback_Result (*OH_AVSessionCallback_OnToggleFavorite)(OH_AVSession* session, const char* assetId, void* userData)
252```
253
254**Description**
255
256Defines a callback for the operation of favoriting a media asset.
257
258**Since**: 13
259
260
261## Enums
262
263
264### AVMetadata_DisplayTag
265
266```
267enum AVMetadata_DisplayTag
268```
269
270**Description**
271
272Enumerates the display tags of the media asset. The display tag is a special type identifier of the media audio source.
273
274**Since**: 13
275
276| Value| Description|
277| -------- | -------- |
278| AVSESSION_DISPLAYTAG_AUDIO_VIVID | AUDIO VIVID.|
279
280
281### AVMetadata_Result
282
283```
284enum AVMetadata_Result
285```
286
287**Description**
288
289Enumerates the error codes related to metadata operations.
290
291**Since**: 13
292
293| Value| Description|
294| -------- | -------- |
295| AVMETADATA_SUCCESS | Operation successful.|
296| AVMETADATA_ERROR_INVALID_PARAM | Incorrect parameter.|
297| AVMETADATA_ERROR_NO_MEMORY | Insufficient memory.|
298
299
300### AVMetadata_SkipIntervals
301
302```
303enum AVMetadata_SkipIntervals
304```
305
306**Description**
307
308Enumerates the fast-forward or rewind intervals supported by the media session.
309
310**Since**: 13
311
312| Value| Description|
313| -------- | -------- |
314| SECONDS_10 | The time is 10 seconds.|
315| SECONDS_15 | The time is 15 seconds.|
316| SECONDS_30 | The time is 30 seconds.|
317
318
319### AVSession_ControlCommand
320
321```
322enum AVSession_ControlCommand
323```
324
325**Description**
326
327Enumerates the playback control commands.
328
329**Since**: 13
330
331| Value| Description|
332| -------- | -------- |
333| CONTROL_CMD_INVALID | Invalid control command.|
334| CONTROL_CMD_PLAY | Play command.|
335| CONTROL_CMD_PAUSE | Pause command.|
336| CONTROL_CMD_STOP | Stop command.|
337| CONTROL_CMD_PLAY_NEXT | Command for playing the next media asset.|
338| CONTROL_CMD_PLAY_PREVIOUS | Command for playing the previous media asset.|
339
340
341### AVSession_ErrCode
342
343```
344enum AVSession_ErrCode
345```
346
347**Description**
348
349Enumerates the playback control error codes.
350
351**Since**: 13
352
353| Value| Description|
354| -------- | -------- |
355| AV_SESSION_ERR_SUCCESS | The operation is successful.|
356| AV_SESSION_ERR_INVALID_PARAMETER | Parameter check fails.|
357| AV_SESSION_ERR_SERVICE_EXCEPTION | The session server is abnormal.|
358| AV_SESSION_ERR_CODE_SESSION_NOT_EXIST | The session does not exist.|
359| AV_SESSION_ERR_CODE_COMMAND_INVALID | The session command is invalid.|
360| AV_SESSION_ERR_CODE_SESSION_INACTIVE | The session is not activated.|
361| AV_SESSION_ERR_CODE_MESSAGE_OVERLOAD | Command and message overflow.|
362
363
364### AVSession_LoopMode
365
366```
367enum AVSession_LoopMode
368```
369
370**Description**
371
372Enumerates the loop modes of media playback.
373
374**Since**: 13
375
376| Value| Description|
377| -------- | -------- |
378| LOOP_MODE_SEQUENCE | Sequential playback.|
379| LOOP_MODE_SINGLE | Single loop.|
380| LOOP_MODE_LIST | Playlist loop.|
381| LOOP_MODE_SHUFFLE | Shuffle.|
382| LOOP_MODE_CUSTOM | Custom playback.|
383
384
385### AVSession_PlaybackState
386
387```
388enum AVSession_PlaybackState
389```
390
391**Description**
392
393Enumerates the media playback states.
394
395**Since**: 13
396
397| Value| Description|
398| -------- | -------- |
399| PLAYBACK_STATE_INITIAL | Initial state.|
400| PLAYBACK_STATE_PREPARING | Ready.|
401| PLAYBACK_STATE_PLAYING | Playing.|
402| PLAYBACK_STATE_PAUSED | Paused.|
403| PLAYBACK_STATE_FAST_FORWARDING | Fast-forwarding.|
404| PLAYBACK_STATE_REWINDED | Rewinded.|
405| PLAYBACK_STATE_STOPPED | Stopped.|
406| PLAYBACK_STATE_COMPLETED | Playback complete.|
407| PLAYBACK_STATE_RELEASED | Released.|
408| PLAYBACK_STATE_ERROR | Error.|
409| PLAYBACK_STATE_IDLE | Idle.|
410| PLAYBACK_STATE_BUFFERING | Buffering.|
411| PLAYBACK_STATE_MAX | Maximum value. (Error code 401 is returned in this case.)|
412
413
414### AVSession_Type
415
416```
417enum AVSession_Type
418```
419
420**Description**
421
422Enumerates the session types.
423
424**Since**: 13
425
426| Value| Description|
427| -------- | -------- |
428| SESSION_TYPE_AUDIO | Audio.|
429| SESSION_TYPE_VIDEO | Video.|
430| SESSION_TYPE_VOICE_CALL | Audio call.|
431| SESSION_TYPE_VIDEO_CALL | Video call.|
432
433
434### AVSessionCallback_Result
435
436```
437enum AVSessionCallback_Result
438```
439
440**Description**
441
442Enumerates the callback execution results.
443
444**Since**: 13
445
446| Value| Description|
447| -------- | -------- |
448| AVSESSION_CALLBACK_RESULT_SUCCESS | The operation is successful.|
449| AVSESSION_CALLBACK_RESULT_FAILURE | The operation fails.|
450
451
452## Function Description
453
454
455### OH_AVMetadata_Destroy()
456
457```
458AVMetadata_Result OH_AVMetadata_Destroy(OH_AVMetadata* avMetadata)
459```
460
461**Description**
462
463Releases an **OH_AVMetadata** object.
464
465**Since**: 13
466
467**Parameters**
468
469| Name| Description|
470| -------- | -------- |
471| avMetadata | Pointer to an **OH_AVMetadata** object.|
472
473**Returns**
474
475Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
476
477**AVMETADATA_SUCCESS**: The function is executed successfully.
478
479**AVMETADATA_ERROR_INVALID_PARAM**: **avMetadata** is a null pointer.
480
481
482### OH_AVMetadataBuilder_Create()
483
484```
485AVMetadata_Result OH_AVMetadataBuilder_Create(OH_AVMetadataBuilder** builder)
486```
487
488**Description**
489
490Creates a metadata builder.
491
492**Since**: 13
493
494**Parameters**
495
496| Name| Description|
497| -------- | -------- |
498| builder | Double pointer to the builder created.|
499
500**Returns**
501
502Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
503
504**AVMETADATA_SUCCESS**: The function is executed successfully.
505
506**AVMETADATA_ERROR_INVALID_PARAM**: **builder** is a null pointer.
507
508**AVMETADATA_ERROR_NO_MEMORY**: There is no sufficient memory.
509
510
511### OH_AVMetadataBuilder_Destroy()
512
513```
514AVMetadata_Result OH_AVMetadataBuilder_Destroy(OH_AVMetadataBuilder* builder)
515```
516
517**Description**
518
519Destroys a metadata builder.
520
521**Since**: 13
522
523**Parameters**
524
525| Name| Description|
526| -------- | -------- |
527| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
528
529**Returns**
530
531Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
532
533**AVMETADATA_SUCCESS**: The function is executed successfully.
534
535**AVMETADATA_ERROR_INVALID_PARAM**: **builder** is a null pointer.
536
537
538### OH_AVMetadataBuilder_GenerateAVMetadata()
539
540```
541AVMetadata_Result OH_AVMetadataBuilder_GenerateAVMetadata(OH_AVMetadataBuilder* builder, OH_AVMetadata** avMetadata)
542```
543
544**Description**
545
546Generates an **OH_AVMetadata** object.
547
548**Since**: 13
549
550**Parameters**
551
552| Name| Description|
553| -------- | -------- |
554| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
555| avMetadata | Double pointer to the **OH_AVMetadata** object created.|
556
557**Returns**
558
559Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
560
561**AVMETADATA_SUCCESS**: The function is executed successfully.
562
563**AVMETADATA_ERROR_NO_MEMORY**: The memory is insufficient.
564
565**AVMETADATA_ERROR_INVALID_PARAM**:
566
5671. **builder** is a null pointer.
568
5692. **avMetadata** is a null pointer.
570
571
572### OH_AVMetadataBuilder_SetAlbum()
573
574```
575AVMetadata_Result OH_AVMetadataBuilder_SetAlbum(OH_AVMetadataBuilder* builder, const char* album)
576```
577
578**Description**
579
580Sets an album name for the media asset.
581
582**Since**: 13
583
584**Parameters**
585
586| Name| Description|
587| -------- | -------- |
588| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
589| album | Pointer to the album name.|
590
591**Returns**
592
593Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
594
595**AVMETADATA_SUCCESS**: The function is executed successfully.
596
597**AVMETADATA_ERROR_INVALID_PARAM**:
5981. **builder** is a null pointer.
599
6002. **album** is a null pointer.
601
602
603### OH_AVMetadataBuilder_SetArtist()
604
605```
606AVMetadata_Result OH_AVMetadataBuilder_SetArtist(OH_AVMetadataBuilder* builder, const char* artist)
607```
608
609**Description**
610
611Sets an artist for the media asset.
612
613**Since**: 13
614
615**Parameters**
616
617| Name| Description|
618| -------- | -------- |
619| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
620| artist | Pointer to the artist.|
621
622**Returns**
623
624Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
625
626**AVMETADATA_SUCCESS**: The function is executed successfully.
627
628**AVMETADATA_ERROR_INVALID_PARAM**:
6291. **builder** is a null pointer.
630
6312. **artist** is a null pointer.
632
633
634### OH_AVMetadataBuilder_SetAssetId()
635
636```
637AVMetadata_Result OH_AVMetadataBuilder_SetAssetId(OH_AVMetadataBuilder* builder, const char* assetId)
638```
639
640**Description**
641
642Sets the ID of the media asset.
643
644**Since**: 13
645
646**Parameters**
647
648| Name| Description|
649| -------- | -------- |
650| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
651| assetId | Pointer to the asset ID.|
652
653**Returns**
654
655Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
656
657**AVMETADATA_SUCCESS**: The function is executed successfully.
658
659**AVMETADATA_ERROR_INVALID_PARAM**:
660
6611. **builder** is a null pointer.
662
6632. **assetId** is a null pointer.
664
665
666### OH_AVMetadataBuilder_SetAuthor()
667
668```
669AVMetadata_Result OH_AVMetadataBuilder_SetAuthor(OH_AVMetadataBuilder* builder, const char* author)
670```
671
672**Description**
673
674Sets an author for the media asset.
675
676**Since**: 13
677
678**Parameters**
679
680| Name| Description|
681| -------- | -------- |
682| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
683| author | Pointer to the author.|
684
685**Returns**
686
687Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
688
689**AVMETADATA_SUCCESS**: The function is executed successfully.
690
691**AVMETADATA_ERROR_INVALID_PARAM**:
692
6931. **builder** is a null pointer.
694
6952. **author** is a null pointer.
696
697
698### OH_AVMetadataBuilder_SetComposer()
699
700```
701AVMetadata_Result OH_AVMetadataBuilder_SetComposer(OH_AVMetadataBuilder* builder, const char* composer)
702```
703
704**Description**
705
706Sets a composer for the media asset.
707
708**Since**: 13
709
710**Parameters**
711
712| Name| Description|
713| -------- | -------- |
714| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
715| composer | Pointer to the composer.|
716
717**Returns**
718
719Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
720
721**AVMETADATA_SUCCESS**: The function is executed successfully.
722
723**AVMETADATA_ERROR_INVALID_PARAM**:
7241. **builder** is a null pointer.
725
7262. **composer** is a null pointer.
727
728
729### OH_AVMetadataBuilder_SetDescription()
730
731```
732AVMetadata_Result OH_AVMetadataBuilder_SetDescription(OH_AVMetadataBuilder* builder, const char* description)
733```
734
735**Description**
736
737Sets a description for the media asset.
738
739**Since**: 13
740
741**Parameters**
742
743| Name| Description|
744| -------- | -------- |
745| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
746| description | Pointer to the description.|
747
748**Returns**
749
750Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
751
752**AVMETADATA_SUCCESS**: The function is executed successfully.
753
754**AVMETADATA_ERROR_INVALID_PARAM**:
755
7561. **builder** is a null pointer.
757
7582. **description** is a null pointer.
759
760
761### OH_AVMetadataBuilder_SetDisplayTags()
762
763```
764AVMetadata_Result OH_AVMetadataBuilder_SetDisplayTags(OH_AVMetadataBuilder* builder, int32_t tags)
765```
766
767**Description**
768
769Sets display tags for the media asset.
770
771**Since**: 13
772
773**Parameters**
774
775| Name| Description|
776| -------- | -------- |
777| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
778| tags | Tags of the media asset displayed on the playback control page.|
779
780**Returns**
781
782Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
783
784**AVMETADATA_SUCCESS**: The function is executed successfully.
785
786**AVMETADATA_ERROR_INVALID_PARAM**: **builder** is a null pointer.
787
788
789### OH_AVMetadataBuilder_SetDuration()
790
791```
792AVMetadata_Result OH_AVMetadataBuilder_SetDuration(OH_AVMetadataBuilder* builder, int64_t duration)
793```
794
795**Description**
796
797Sets the playback duration for the media asset.
798
799**Since**: 13
800
801**Parameters**
802
803| Name| Description|
804| -------- | -------- |
805| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
806| duration | Playback duration, in ms.|
807
808**Returns**
809
810Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
811
812**AVMETADATA_SUCCESS**: The function is executed successfully.
813
814**AVMETADATA_ERROR_INVALID_PARAM**: **builder** is a null pointer.
815
816
817### OH_AVMetadataBuilder_SetLyric()
818
819```
820AVMetadata_Result OH_AVMetadataBuilder_SetLyric(OH_AVMetadataBuilder* builder, const char* lyric)
821```
822
823**Description**
824
825Sets lyrics for the media asset.
826
827**Since**: 13
828
829**Parameters**
830
831| Name| Description|
832| -------- | -------- |
833| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
834| lyric | Pointer to the lyrics in the lrc format.|
835
836**Returns**
837
838Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
839
840**AVMETADATA_SUCCESS**: The function is executed successfully.
841
842**AVMETADATA_ERROR_INVALID_PARAM**:
843
8441. **builder** is a null pointer.
845
8462. **lyric** is a null pointer.
847
848
849### OH_AVMetadataBuilder_SetMediaImageUri()
850
851```
852AVMetadata_Result OH_AVMetadataBuilder_SetMediaImageUri(OH_AVMetadataBuilder* builder, const char* mediaImageUri)
853```
854
855**Description**
856
857Sets an image for the media asset.
858
859**Since**: 13
860
861**Parameters**
862
863| Name| Description|
864| -------- | -------- |
865| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
866| mediaImageUri | Pointer to the URI of the image.|
867
868**Returns**
869
870Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
871
872**AVMETADATA_SUCCESS**: The function is executed successfully.
873
874**AVMETADATA_ERROR_INVALID_PARAM**:
875
8761. **builder** is a null pointer.
877
8782. **mediaImageUri** is a null pointer.
879
880
881### OH_AVMetadataBuilder_SetSkipIntervals()
882
883```
884AVMetadata_Result OH_AVMetadataBuilder_SetSkipIntervals(OH_AVMetadataBuilder* builder, AVMetadata_SkipIntervals intervals)
885```
886
887**Description**
888
889Sets the skip intervals for the media asset.
890
891**Since**: 13
892
893**Parameters**
894
895| Name| Description|
896| -------- | -------- |
897| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
898| intervals | Skip intervals.|
899
900**Returns**
901
902Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
903
904**AVMETADATA_SUCCESS**: The function is executed successfully.
905
906**AVMETADATA_ERROR_INVALID_PARAM**:
907
9081. **builder** is a null pointer.
909
9102. **intervals** is invalid.
911
912
913### OH_AVMetadataBuilder_SetSubtitle()
914
915```
916AVMetadata_Result OH_AVMetadataBuilder_SetSubtitle(OH_AVMetadataBuilder* builder, const char* subtitle)
917```
918
919**Description**
920
921Sets a subtitle for the media asset.
922
923**Since**: 13
924
925**Parameters**
926
927| Name| Description|
928| -------- | -------- |
929| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
930| subtitle | Pointer to the subtitle.|
931
932**Returns**
933
934Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
935
936**AVMETADATA_SUCCESS**: The function is executed successfully.
937
938**AVMETADATA_ERROR_INVALID_PARAM**:
939
9401. **builder** is a null pointer.
941
9422. **subtitle** is a null pointer.
943
944
945### OH_AVMetadataBuilder_SetTitle()
946
947```
948AVMetadata_Result OH_AVMetadataBuilder_SetTitle(OH_AVMetadataBuilder* builder, const char* title)
949```
950
951**Description**
952
953Sets a title for the media asset.
954
955**Since**: 13
956
957**Parameters**
958
959| Name| Description|
960| -------- | -------- |
961| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
962| title | Pointer to the title.|
963
964**Returns**
965
966Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
967
968**AVMETADATA_SUCCESS**: The function is executed successfully.
969
970**AVMETADATA_ERROR_INVALID_PARAM**:
9711. **builder** is a null pointer.
972
9732. **title** is a null pointer.
974
975
976### OH_AVMetadataBuilder_SetWriter()
977
978```
979AVMetadata_Result OH_AVMetadataBuilder_SetWriter(OH_AVMetadataBuilder* builder, const char* writer)
980```
981
982**Description**
983
984Sets a writer for the media asset.
985
986**Since**: 13
987
988**Parameters**
989
990| Name| Description|
991| -------- | -------- |
992| builder | Pointer to an **OH_AVMetadataBuilder** instance.|
993| writer | Pointer to the writer.|
994
995**Returns**
996
997Returns one of the following result codes defined in [AVMetadata_Result](#avmetadata_result):
998
999**AVMETADATA_SUCCESS**: The function is executed successfully.
1000
1001**AVMETADATA_ERROR_INVALID_PARAM**:
10021. **builder** is a null pointer.
1003
10042. **writer** is a null pointer.
1005
1006
1007### OH_AVSession_Activate()
1008
1009```
1010AVSession_ErrCode OH_AVSession_Activate(OH_AVSession* avsession)
1011```
1012
1013**Description**
1014
1015Activates a session.
1016
1017**Since**: 13
1018
1019**Parameters**
1020
1021| Name| Description|
1022| -------- | -------- |
1023| avsession | Pointer to a session object.|
1024
1025**Returns**
1026
1027Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1028
1029**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1030
1031**AV_SESSION_ERR_INVALID_PARAMETER**: **avsession** is a null pointer.
1032
1033**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1034
1035
1036### OH_AVSession_Create()
1037
1038```
1039AVSession_ErrCode OH_AVSession_Create(AVSession_Type sessionType, const char* sessionTag, const char* bundleName, const char* abilityName, OH_AVSession** avsession)
1040```
1041
1042**Description**
1043
1044Creates a session object.
1045
1046**Since**: 13
1047
1048**Parameters**
1049
1050| Name| Description|
1051| -------- | -------- |
1052| sessionType | Session type. For details about the available options, see [AVSession_Type](#avsession_type).|
1053| sessionTag | Pointer to the session tag.|
1054| bundleName | Pointer to the bundle name.|
1055| abilityName | Pointer to the ability name.|
1056| avsession | Double pointer to the session object created.|
1057
1058**Returns**
1059
1060Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1061
1062**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1063
1064**link AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal or the session object already exists.
1065
1066**AV_SESSION_ERR_INVALID_PARAMETER**:
1067
10681. **sessionType** is invalid.
1069
10702. **sessionTag** is a null pointer.
1071
10723. **bundleName** is a null pointer.
1073
10744. **abilityName** is a null pointer.
1075
10765. **avsession** is a null pointer.
1077
1078
1079### OH_AVSession_Deactivate()
1080
1081```
1082AVSession_ErrCode OH_AVSession_Deactivate(OH_AVSession* avsession)
1083```
1084
1085**Description**
1086
1087Deactivates a session.
1088
1089**Since**: 13
1090
1091**Parameters**
1092
1093| Name| Description|
1094| -------- | -------- |
1095| avsession | Pointer to a session object.|
1096
1097**Returns**
1098
1099Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1100
1101**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1102
1103**AV_SESSION_ERR_INVALID_PARAMETER**: **avsession** is a null pointer.
1104
1105**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1106
1107
1108### OH_AVSession_Destroy()
1109
1110```
1111AVSession_ErrCode OH_AVSession_Destroy(OH_AVSession* avsession)
1112```
1113
1114**Description**
1115
1116Destroys a session object.
1117
1118**Since**: 13
1119
1120**Parameters**
1121
1122| Name| Description|
1123| -------- | -------- |
1124| avsession | Pointer to a session object.|
1125
1126**Returns**
1127
1128Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1129
1130**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1131
1132**AV_SESSION_ERR_INVALID_PARAMETER**: **avsession** is a null pointer.
1133
1134
1135### OH_AVSession_GetSessionId()
1136
1137```
1138AVSession_ErrCode OH_AVSession_GetSessionId(OH_AVSession* avsession, const char** sessionId)
1139```
1140
1141**Description**
1142
1143Obtains the session ID.
1144
1145**Since**: 13
1146
1147**Parameters**
1148
1149| Name| Description|
1150| -------- | -------- |
1151| avsession | Pointer to a session object.|
1152| sessionId | Double pointer to the session ID obtained.|
1153
1154**Returns**
1155
1156Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1157
1158**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1159
1160**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal or an error occurs.
1161
1162**AV_SESSION_ERR_INVALID_PARAMETER**:
1163
11641. **avsession** is a null pointer.
1165
11662. **sessionId** is a null pointer.
1167
1168
1169### OH_AVSession_GetSessionType()
1170
1171```
1172AVSession_ErrCode OH_AVSession_GetSessionType(OH_AVSession* avsession, AVSession_Type* sessionType)
1173```
1174
1175**Description**
1176
1177Obtains the session type.
1178
1179**Since**: 13
1180
1181**Parameters**
1182
1183| Name| Description|
1184| -------- | -------- |
1185| avsession | Pointer to a session object.|
1186| sessionType | Pointer to the session type obtained.|
1187
1188**Returns**
1189
1190Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1191
1192**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1193
1194**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal or an error occurs.
1195
1196**AV_SESSION_ERR_INVALID_PARAMETER**:
1197
11981. **avsession** is a null pointer.
1199
12002. **sessionType** is a null pointer.
1201
1202
1203### OH_AVSession_RegisterCommandCallback()
1204
1205```
1206AVSession_ErrCode OH_AVSession_RegisterCommandCallback(OH_AVSession* avsession, AVSession_ControlCommand command, OH_AVSessionCallback_OnCommand callback, void* userData)
1207```
1208
1209**Description**
1210
1211Registers a callback for a common playback control command.
1212
1213**Since**: 13
1214
1215**Parameters**
1216
1217| Name| Description|
1218| -------- | -------- |
1219| avsession | Pointer to a session object.|
1220| command | Playback control command.|
1221| callback | Callback to register, which is [OH_AVSessionCallback_OnCommand](#oh_avsessioncallback_oncommand).|
1222| userData | Pointer to the application data passed through the callback functions.|
1223
1224**Returns**
1225
1226Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1227
1228**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1229
1230**AV_SESSION_ERR_CODE_COMMAND_INVALID**: The playback control command is invalid.
1231
1232**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1233
1234**AV_SESSION_ERR_INVALID_PARAMETER**:
1235
12361. **avsession** is a null pointer.
1237
12382. **callback** is a null pointer.
1239
1240
1241### OH_AVSession_RegisterForwardCallback()
1242
1243```
1244AVSession_ErrCode OH_AVSession_RegisterForwardCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnFastForward callback, void* userData)
1245```
1246
1247**Description**
1248
1249Registers a callback for the fast-forward operation.
1250
1251**Since**: 13
1252
1253**Parameters**
1254
1255| Name| Description|
1256| -------- | -------- |
1257| avsession | Pointer to a session object.|
1258| callback | Callback to register, which issue [OH_AVSessionCallback_OnFastForward](#oh_avsessioncallback_onfastforward).|
1259| userData | Pointer to the application data passed through the callback functions.|
1260
1261**Returns**
1262
1263Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1264
1265**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1266
1267**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1268
1269**AV_SESSION_ERR_INVALID_PARAMETER**:
1270
12711. **avsession** is a null pointer.
1272
12732. **callback** is a null pointer.
1274
1275
1276### OH_AVSession_RegisterRewindCallback()
1277
1278```
1279AVSession_ErrCode OH_AVSession_RegisterRewindCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnRewind callback, void* userData)
1280```
1281
1282**Description**
1283
1284Registers a callback for the rewind operation.
1285
1286**Since**: 13
1287
1288**Parameters**
1289
1290| Name| Description|
1291| -------- | -------- |
1292| avsession | Pointer to a session object.|
1293| callback | Callback to register, which is [OH_AVSessionCallback_OnRewind](#oh_avsessioncallback_onrewind).|
1294| userData | Pointer to the application data passed through the callback functions.|
1295
1296**Returns**
1297
1298Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1299
1300**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1301
1302**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1303
1304**AV_SESSION_ERR_INVALID_PARAMETER**:
1305
13061. **avsession** is a null pointer.
1307
13082. **callback** is a null pointer.
1309
1310
1311### OH_AVSession_RegisterSeekCallback()
1312
1313```
1314AVSession_ErrCode OH_AVSession_RegisterSeekCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnSeek callback, void* userData)
1315```
1316
1317**Description**
1318
1319Registers a callback for the seek operation.
1320
1321**Since**: 13
1322
1323**Parameters**
1324
1325| Name| Description|
1326| -------- | -------- |
1327| avsession | Pointer to a session object.|
1328| callback | Callback to register, which is [OH_AVSessionCallback_OnSeek](#oh_avsessioncallback_onseek).|
1329| userData | Pointer to the application data passed through the callback functions.|
1330
1331**Returns**
1332
1333Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1334
1335**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1336
1337**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1338
1339**AV_SESSION_ERR_INVALID_PARAMETER**:
1340
13411. **avsession** is a null pointer.
1342
13432. **callback** is a null pointer.
1344
1345
1346### OH_AVSession_RegisterSetLoopModeCallback()
1347
1348```
1349AVSession_ErrCode OH_AVSession_RegisterSetLoopModeCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnSetLoopMode callback, void* userData)
1350```
1351
1352**Description**
1353
1354Registers a callback for the operation of setting the loop mode.
1355
1356**Since**: 13
1357
1358**Parameters**
1359
1360| Name| Description|
1361| -------- | -------- |
1362| avsession | Pointer to a session object.|
1363| callback | Callback to register, which is [OH_AVSessionCallback_OnSetLoopMode](#oh_avsessioncallback_onsetloopmode).|
1364| userData | Pointer to the application data passed through the callback functions.|
1365
1366**Returns**
1367
1368Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1369
1370**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1371
1372**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1373
1374**AV_SESSION_ERR_INVALID_PARAMETER**:
1375
13761. **avsession** is a null pointer.
1377
13782. **callback** is a null pointer.
1379
1380
1381### OH_AVSession_RegisterToggleFavoriteCallback()
1382
1383```
1384AVSession_ErrCode OH_AVSession_RegisterToggleFavoriteCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnToggleFavorite callback, void* userData)
1385```
1386
1387**Description**
1388
1389Registers a callback for the operation of favoriting a media asset.
1390
1391**Since**: 13
1392
1393**Parameters**
1394
1395| Name| Description|
1396| -------- | -------- |
1397| avsession | Pointer to a session object.|
1398| callback | Callback to register, which is [OH_AVSessionCallback_OnToggleFavorite](#oh_avsessioncallback_ontogglefavorite).|
1399| userData | Pointer to the application data passed through the callback functions.|
1400
1401**Returns**
1402
1403Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1404
1405**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1406
1407**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1408
1409**AV_SESSION_ERR_INVALID_PARAMETER**:
1410
14111. **avsession** is a null pointer.
1412
14132. **callback** is a null pointer.
1414
1415
1416### OH_AVSession_SetAVMetadata()
1417
1418```
1419AVSession_ErrCode OH_AVSession_SetAVMetadata(OH_AVSession* avsession, OH_AVMetadata* avmetadata)
1420```
1421
1422**Description**
1423
1424Sets media metadata.
1425
1426**Since**: 13
1427
1428**Parameters**
1429
1430| Name| Description|
1431| -------- | -------- |
1432| avsession | Pointer to a session object.|
1433| avmetadata | Pointer to the media metadata.|
1434
1435**Returns**
1436
1437Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1438
1439**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1440
1441**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1442
1443**AV_SESSION_ERR_INVALID_PARAMETER**:
1444
14451. **avsession** is a null pointer.
1446
14472. **avmetadata** is a null pointer.
1448
1449
1450### OH_AVSession_SetFavorite()
1451
1452```
1453AVSession_ErrCode OH_AVSession_SetFavorite(OH_AVSession* avsession, bool favorite)
1454```
1455
1456**Description**
1457
1458Favorites or unfavorites the media asset.
1459
1460**Since**: 13
1461
1462**Parameters**
1463
1464| Name| Description|
1465| -------- | -------- |
1466| avsession | Pointer to a session object.|
1467| favorite | Whether to favorite or unfavorite the media asset. The value **true** means to favorite the media asset, and **false** means the opposite.|
1468
1469**Returns**
1470
1471Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1472
1473**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1474
1475**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1476
1477**AV_SESSION_ERR_INVALID_PARAMETER**: **avsession** is a null pointer.
1478
1479
1480### OH_AVSession_SetLoopMode()
1481
1482```
1483AVSession_ErrCode OH_AVSession_SetLoopMode(OH_AVSession* avsession, AVSession_LoopMode loopMode)
1484```
1485
1486**Description**
1487
1488Sets a loop mode.
1489
1490**Since**: 13
1491
1492**Parameters**
1493
1494| Name| Description|
1495| -------- | -------- |
1496| avsession | Pointer to a session object.|
1497| loopMode | Loop mode.|
1498
1499**Returns**
1500
1501Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1502
1503**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1504
1505**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1506
1507**AV_SESSION_ERR_INVALID_PARAMETER**:
1508
15091. **avsession** is a null pointer.
1510
15112. **loopMode** is invalid.
1512
1513
1514### OH_AVSession_SetPlaybackPosition()
1515
1516```
1517AVSession_ErrCode OH_AVSession_SetPlaybackPosition(OH_AVSession* avsession, AVSession_PlaybackPosition* playbackPosition)
1518```
1519
1520**Description**
1521
1522Sets the playback position.
1523
1524**Since**: 13
1525
1526**Parameters**
1527
1528| Name| Description|
1529| -------- | -------- |
1530| avsession | Pointer to a session object.|
1531| playbackPosition | Pointer to the playback position.|
1532
1533**Returns**
1534
1535Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1536
1537**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1538
1539**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1540
1541**AV_SESSION_ERR_INVALID_PARAMETER**:
1542
15431. **avsession** is a null pointer.
1544
15452. **playbackPosition** is a null pointer.
1546
1547
1548### OH_AVSession_SetPlaybackState()
1549
1550```
1551AVSession_ErrCode OH_AVSession_SetPlaybackState(OH_AVSession* avsession, AVSession_PlaybackState playbackState)
1552```
1553
1554**Description**
1555
1556Sets the playback state.
1557
1558**Since**: 13
1559
1560**Parameters**
1561
1562| Name| Description|
1563| -------- | -------- |
1564| avsession | Pointer to a session object.|
1565| playbackState | Playback state.|
1566
1567**Returns**
1568
1569Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1570
1571**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1572
1573**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1574
1575**AV_SESSION_ERR_INVALID_PARAMETER**:
1576
15771. **avsession** is a null pointer.
1578
15792. **playbackState** is invalid.
1580
1581
1582### OH_AVSession_UnregisterCommandCallback()
1583
1584```
1585AVSession_ErrCode OH_AVSession_UnregisterCommandCallback(OH_AVSession* avsession, AVSession_ControlCommand command, OH_AVSessionCallback_OnCommand callback)
1586```
1587
1588**Description**
1589
1590Unregisters the callback for a common playback control command.
1591
1592**Since**: 13
1593
1594**Parameters**
1595
1596| Name| Description|
1597| -------- | -------- |
1598| avsession | Pointer to a session object.|
1599| command | Playback control command.|
1600| callback | Callback to unregister, which is [OH_AVSessionCallback_OnCommand](#oh_avsessioncallback_oncommand).|
1601
1602**Returns**
1603
1604Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1605
1606**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1607
1608**AV_SESSION_ERR_CODE_COMMAND_INVALID**: The playback control command is invalid.
1609
1610**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1611
1612**AV_SESSION_ERR_INVALID_PARAMETER**:
1613
16141. **avsession** is a null pointer.
1615
16162. **callback** is a null pointer.
1617
1618
1619### OH_AVSession_UnregisterForwardCallback()
1620
1621```
1622AVSession_ErrCode OH_AVSession_UnregisterForwardCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnFastForward callback)
1623```
1624
1625**Description**
1626
1627Unregisters the callback for the fast-forward operation.
1628
1629**Since**: 13
1630
1631**Parameters**
1632
1633| Name| Description|
1634| -------- | -------- |
1635| avsession | Pointer to a session object.|
1636| callback | Callback to unregister, which issue [OH_AVSessionCallback_OnFastForward](#oh_avsessioncallback_onfastforward).|
1637
1638**Returns**
1639
1640Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1641
1642**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1643
1644**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1645
1646**AV_SESSION_ERR_INVALID_PARAMETER**:
1647
16481. **avsession** is a null pointer.
1649
16502. **callback** is a null pointer.
1651
1652
1653### OH_AVSession_UnregisterRewindCallback()
1654
1655```
1656AVSession_ErrCode OH_AVSession_UnregisterRewindCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnRewind callback)
1657```
1658
1659**Description**
1660
1661Unregisters the callback for the rewind operation.
1662
1663**Since**: 13
1664
1665**Parameters**
1666
1667| Name| Description|
1668| -------- | -------- |
1669| avsession | Pointer to a session object.|
1670| callback | Callback to unregister, which is [OH_AVSessionCallback_OnRewind](#oh_avsessioncallback_onrewind).|
1671
1672**Returns**
1673
1674Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1675
1676**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1677
1678**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1679
1680**AV_SESSION_ERR_INVALID_PARAMETER**:
1681
16821. **avsession** is a null pointer.
1683
16842. **callback** is a null pointer.
1685
1686
1687### OH_AVSession_UnregisterSeekCallback()
1688
1689```
1690AVSession_ErrCode OH_AVSession_UnregisterSeekCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnSeek callback)
1691```
1692
1693**Description**
1694
1695Unregisters the callback for the seek operation.
1696
1697**Since**: 13
1698
1699**Parameters**
1700
1701| Name| Description|
1702| -------- | -------- |
1703| avsession | Pointer to a session object.|
1704| callback | Callback to unregister, which is [OH_AVSessionCallback_OnSeek](#oh_avsessioncallback_onseek).|
1705
1706**Returns**
1707
1708Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1709
1710**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1711
1712**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1713
1714**AV_SESSION_ERR_INVALID_PARAMETER**:
1715
17161. **avsession** is a null pointer.
1717
17182. **callback** is a null pointer.
1719
1720
1721### OH_AVSession_UnregisterSetLoopModeCallback()
1722
1723```
1724AVSession_ErrCode OH_AVSession_UnregisterSetLoopModeCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnSetLoopMode callback)
1725```
1726
1727**Description**
1728
1729Unregisters the callback for the operation of setting the loop mode.
1730
1731**Since**: 13
1732
1733**Parameters**
1734
1735| Name| Description|
1736| -------- | -------- |
1737| avsession | Pointer to a session object.|
1738| callback | Callback to unregister, which is [OH_AVSessionCallback_OnSetLoopMode](#oh_avsessioncallback_onsetloopmode).|
1739
1740**Returns**
1741
1742Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1743
1744**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1745
1746**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1747
1748**AV_SESSION_ERR_INVALID_PARAMETER**:
1749
17501. **avsession** is a null pointer.
1751
17522. **callback** is a null pointer.
1753
1754
1755### OH_AVSession_UnregisterToggleFavoriteCallback()
1756
1757```
1758AVSession_ErrCode OH_AVSession_UnregisterToggleFavoriteCallback(OH_AVSession* avsession, OH_AVSessionCallback_OnToggleFavorite callback)
1759```
1760
1761**Description**
1762
1763Unregisters the callback for the operation of favoriting a media asset.
1764
1765**Since**: 13
1766
1767**Parameters**
1768
1769| Name| Description|
1770| -------- | -------- |
1771| avsession | Pointer to a session object.|
1772| callback | Callback to unregister, which is [OH_AVSessionCallback_OnToggleFavorite](#oh_avsessioncallback_ontogglefavorite).|
1773
1774**Returns**
1775
1776Returns one of the following result codes defined in [AVSession_ErrCode](#avsession_errcode):
1777
1778**AV_SESSION_ERR_SUCCESS**: The function is executed successfully.
1779
1780**AV_SESSION_ERR_SERVICE_EXCEPTION**: The session service is abnormal.
1781
1782**AV_SESSION_ERR_INVALID_PARAMETER**:
1783
17841. **avsession** is a null pointer.
1785
17862. **callback** is a null pointer.
1787