Declares the definitions of the playback controller.
File to include:: <multimedia/av_session/native_avcastcontroller.h>
Library: libohavsession.so
System capability: SystemCapability.Multimedia.AVSession.Core
Since: 23
Related module: OHAVSession
| Name | typedef Keyword | Description |
|---|---|---|
| OH_AVCastController | OH_AVCastController | Defines the playback controller object. You can use the OH_AVSession_CreateAVCastController method to create a pointer. |
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_PlaybackStateChanged)(OH_AVCastController* avcastcontroller, OH_AVSession_AVPlaybackState* playbackState, void* userData)
Description
Triggered when the playback state changes.
Since: 23
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_MediaItemChange)(OH_AVCastController* avcastcontroller, OH_AVSession_AVQueueItem* avQueueItem, void* userData)
Description
Triggered when the media item changes.
Since: 23
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_PlayNext)(OH_AVCastController* avcastcontroller, void* userData)
Description
Triggered when the next track is played.
Since: 23
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_PlayPrevious)(OH_AVCastController* avcastcontroller, void* userData)
Description
Triggered when the previous track is played.
Since: 23
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_SeekDone)(OH_AVCastController* avcastcontroller, int32_t position, void* userData)
Description
Triggered when the seek is complete.
Since: 23
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_EndOfStream)(OH_AVCastController* avcastcontroller, void* userData)
Description
Triggered when the playback stream ends.
Since: 23
typedef AVSessionCallback_Result(*OH_AVCastControllerCallback_Error)(OH_AVCastController* avcastcontroller, void* userData, AVSession_ErrCode error)
Description
Triggered when a playback error occurs.
Since: 23
AVSession_ErrCode OH_AVCastController_Destroy(OH_AVCastController* avcastcontroller)
Description
Requests to destroy the playback controller object.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: The avcastcontroller parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_GetPlaybackState(OH_AVCastController* avcastcontroller, OH_AVSession_AVPlaybackState** playbackState)
Description
Obtains the playback state of the current player. Do not release the playbackState pointer separately. When OH_AVCastController_Destroy is called, this pointer will be destroyed together with the playback controller.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVSession_AVPlaybackState** playbackState | Double pointer to the playback state. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The playbackState parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterPlaybackStateChangedCallback(OH_AVCastController* avcastcontroller, int32_t filter, OH_AVCastControllerCallback_PlaybackStateChanged callback, void* userData)
Description
Requests to register a callback for playback state changes.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| int32_t filter | AVSession_PlaybackFilter used to determine the parameters to be included in the callback. |
| OH_AVCastControllerCallback_PlaybackStateChanged callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. 3. The filter parameter is invalid. |
AVSession_ErrCode OH_AVCastController_UnregisterPlaybackStateChangedCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_PlaybackStateChanged callback)
Description
Requests to unregister a callback for playback state changes.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_PlaybackStateChanged callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterMediaItemChangedCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_MediaItemChange callback, void* userData)
Description
Requests to register a callback for changes to the media item being played.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_MediaItemChange callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_UnregisterMediaItemChangedCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_MediaItemChange callback)
Description
Requests to unregister a callback for changes to the media item being played.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_MediaItemChange callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterPlayNextCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_PlayNext callback, void* userData)
Description
Requests to register a callback for the next track request sent by the remote device or media center.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_PlayNext callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_UnregisterPlayNextCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_PlayNext callback)
Description
Requests to unregister a callback for the next track request sent by the remote device or media center.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_PlayNext callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterPlayPreviousCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_PlayPrevious callback, void* userData)
Description
Requests to register a callback for the previous track request sent by the remote device or media center.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_PlayPrevious callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_UnregisterPlayPreviousCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_PlayPrevious callback)
Description
Requests to unregister a callback for the previous track request sent by the remote device or media center.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_PlayPrevious callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterSeekDoneCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_SeekDone callback, void* userData)
Description
Requests to register a callback for the seek completion.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_SeekDone callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_UnregisterSeekDoneCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_SeekDone callback)
Description
Requests to unregister the callback for the seek completion.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_SeekDone callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterEndOfStreamCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_EndOfStream callback, void* userData)
Description
Requests to register a callback for the end of stream.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_EndOfStream callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_UnregisterEndOfStreamCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_EndOfStream callback)
Description
Requests to unregister a callback for the end of stream.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_EndOfStream callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_RegisterErrorCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_Error callback, void* userData)
Description
Requests to register a callback for the playback error event.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_Error callback | Callback to register. |
| void* userData | Pointer to the user data passed by the user. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_UnregisterErrorCallback(OH_AVCastController* avcastcontroller, OH_AVCastControllerCallback_Error callback)
Description
Requests to unregister a callback for the playback error event.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVCastControllerCallback_Error callback | Callback to unregister. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The callback parameter is nullptr. |
AVSession_ErrCode OH_AVCastController_SendCommonCommand(OH_AVCastController* avcastcontroller, AVSession_AVCastControlCommandType* avCastControlcommand)
Description
Requests to send a common command to the remote device. Only commands such as play, pause, stop, next, and previous are supported.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| AVSession_AVCastControlCommandType* avCastControlcommand | Pointer to the control command. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: The avcastcontroller parameter is nullptr. AV_SESSION_ERR_CODE_COMMAND_INVALID: The avCastControlcommand parameter is invalid. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_SendSeekCommand(OH_AVCastController* avcastcontroller, int32_t seekTimeMS)
Description
Requests to send a seek command to the remote device.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| int32_t seekTimeMS | Seek time, in milliseconds. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The seekTimeMS parameter is invalid. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_SendFastForwardCommand(OH_AVCastController* avcastcontroller, int32_t forwardTimeS)
Description
Requests to send a fast-forward command to the remote device.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| int32_t forwardTimeS | Fast-forward time, in seconds. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The forwardTimeS parameter is invalid. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_SendRewindCommand(OH_AVCastController* avcastcontroller, int32_t rewindTimeS)
Description
Requests to send a rewind command to the remote device.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| int32_t rewindTimeS | Rewind time, in seconds. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The rewindTimeS parameter is invalid. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_SendSetSpeedCommand(OH_AVCastController* avcastcontroller, AVSession_PlaybackSpeed speed)
Description
Requests to send a speed setting command to the remote device.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| AVSession_PlaybackSpeed speed | Speed control command. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The speed parameter is invalid. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_SendVolumeCommand(OH_AVCastController* avcastcontroller, int32_t volume)
Description
Requests to send a volume control command to the remote device.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| int32_t volume | Volume. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The volume parameter is invalid. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_Prepare(OH_AVCastController* avcastcontroller, OH_AVSession_AVQueueItem* avqueueItem)
Description
Requests to prepare the current audio or video playback queue item. This operation is a prerequisite for displaying output media information.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVSession_AVQueueItem* avqueueItem | Pointer to the audio and video queue item. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The avqueueItem parameter is nullptr. AV_SESSION_ERR_CODE_REMOTE_CONNECTION_NOT_EXIST: The remote connection is not established. |
AVSession_ErrCode OH_AVCastController_Start(OH_AVCastController* avcastcontroller, OH_AVSession_AVQueueItem* avqueueItem)
Description
Requests to play the current item. The parameter should contain media resources; otherwise, playback will fail.
Since: 23
Parameters
| Name | Description |
|---|---|
| OH_AVCastController* avcastcontroller | Pointer to the instance object of the playback controller. |
| OH_AVSession_AVQueueItem* avqueueItem | Pointer to the audio and video queue item. |
Return value
| Type | Description |
|---|---|
| AVSession_ErrCode | AV_SESSION_ERR_SUCCESS: The function is executed successfully. AV_SESSION_ERR_SERVICE_EXCEPTION: Internal server error. AV_SESSION_ERR_INVALID_PARAMETER: 1. The avcastcontroller parameter is nullptr. 2. The avqueueItem parameter is nullptr. |