public abstract class AVSessionCallback extends Object
AVSession.setAVSessionCallback(ohos.media.common.sessioncore.AVSessionCallback)
to register callbacks to listen to media sessions.SystemCapability.Multimedia#MEDIA| 构造器 | 说明 |
|---|---|
AVSessionCallback() |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
onCommand(String command,
PacMap options,
GeneralReceiver callback) |
Called when the
ohos.media.sessioncore.AVController sends a command to the media session. |
boolean |
onMediaButtonEvent(Intent mediaButtonIntent) |
Called when a button event is triggered and the media session has the highest priority,
or when the
AVController sends a button event to the session. |
void |
onPause() |
Called when the application is requested to pause the ongoing playback.
|
void |
onPlay() |
Called when the application is requested to start playback.
|
void |
onPlayByMediaId(String mediaId,
PacMap options) |
Called when the application is requested to play the media item specified by
the
AVBrowserService of the application. |
void |
onPlayBySearch(String query,
PacMap options) |
Called when the application is requested to play a search result.
|
void |
onPlayByUri(Uri uri,
PacMap options) |
Called when the application is requested to play the media item specified by a URI.
|
void |
onPlayFastForward() |
Called when the application is requested to fast forward the media item.
|
void |
onPlayNext() |
Called when the application is requested to play the next media item.
|
void |
onPlayPrevious() |
Called when the application is requested to play the previous media item.
|
void |
onPrepareToPlay() |
Called when the application is requested to prepare for playback.
|
void |
onPrepareToPlayByMediaId(String mediaId,
PacMap options) |
Called when the application is requested to prepare for playing the media
item specified by the
AVBrowserService. |
void |
onPrepareToPlayBySearch(String query,
PacMap options) |
Called when the application is requested to prepare for starting playback from a search result.
|
void |
onPrepareToPlayByUri(Uri uri,
PacMap options) |
Called when the application is requested to prepare for playing the media item specified by a URI.
|
void |
onRewind() |
Called when the application is requested to rewind the media item.
|
void |
onSeekTo(long position) |
Called when the application is requested to skip to a specified playback position.
|
void |
onSetAVPlaybackCustomAction(String action,
PacMap options) |
Called when the
AVController is about to execute a custom playback action
defined
in AVPlaybackState.AVPlaybackCustomAction. |
void |
onSetAVPlaybackSpeed(float speed) |
Called when the application is requested to change the playback speed.
|
void |
onSkipToAVQueueElement(long queueId) |
Called when the application is requested to play a specified media item.
|
void |
onStop() |
Called when the application is requested to stop playing.
|
public void onCommand(String command, PacMap options, GeneralReceiver callback)
ohos.media.sessioncore.AVController sends a command to the media session.
The media session owner can process custom commands.command - Indicates the command name.options - Indicates optional parameters of the command.callback - Indicates the callback that receives the execution result. This parameter can be null.public boolean onMediaButtonEvent(Intent mediaButtonIntent)
AVController sends a button event to the session.mediaButtonIntent - Indicates the intent that contains
the AVSession.PARAM_KEY_EVENT field
specifying a KeyEvent object, based on which playback is controlled.
This intent is of the AVSession.ACTION_MEDIA_BUTTON type.true if the key event in the intent has been processed; returns false otherwise.public void onPrepareToPlay()
You can override this callback to handle the request. After the preparation is completed,
the playback state should be changed to AVPlaybackState#PLAYBACK_STATE_PAUSED.
public void onPrepareToPlayByMediaId(String mediaId, PacMap options)
AVBrowserService.
You can override this callback to handle the request. After the preparation is completed,
the playback state should be changed to AVPlaybackState#PLAYBACK_STATE_PAUSED.
mediaId - Identifies the media item.options - Indicates additional information about the media item.public void onPrepareToPlayBySearch(String query, PacMap options)
You can override this callback to handle the request. After the preparation is completed,
the playback state should be changed to AVPlaybackState#PLAYBACK_STATE_PAUSED.
query - Indicates the search criteria. If this parameter is null,
the application can prepare for any media item.options - Indicates additional data to search for.public void onPrepareToPlayByUri(Uri uri, PacMap options)
You can override this callback to handle the request. After the preparation is completed,
the playback state should be changed to AVPlaybackState#PLAYBACK_STATE_PAUSED.
uri - Indicates the media item URI.options - Indicates additional information about the media item.public void onPlay()
You can override this callback to handle the request.
public void onPlayBySearch(String query, PacMap options)
query - Indicates the search criteria. If this parameter is null,
the application can play any media item.options - Indicates additional data to search for.public void onPlayByMediaId(String mediaId, PacMap options)
AVBrowserService of the application.
You can override this callback to handle the request.
mediaId - Indicates the media item ID.options - Indicates additional information about the media item.public void onPlayByUri(Uri uri, PacMap options)
You can override this callback to handle the request.
uri - Indicates the media item URI.options - Indicates additional information about the media item.public void onSkipToAVQueueElement(long queueId)
You can override this callback to handle the request.
queueId - Indicates the media item to play.public void onPause()
You can override this callback to handle the request.
public void onSeekTo(long position)
You can override this callback to handle the request.
position - Indicates the playback position (milliseconds) to skip to.public void onPlayNext()
You can override this callback to handle the request.
public void onPlayPrevious()
You can override this callback to handle the request.
public void onPlayFastForward()
You can override this callback to handle the request.
public void onRewind()
You can override this callback to handle the request.
public void onStop()
You can override this callback to handle the request.
public void onSetAVPlaybackSpeed(float speed)
speed - Indicates the target playback speed.public void onSetAVPlaybackCustomAction(String action, PacMap options)
AVController is about to execute a custom playback action
defined
in AVPlaybackState.AVPlaybackCustomAction.action - Indicates the custom playback action.options - Indicates additional data for the action.