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