public final class AVController extends Object
AVSessionSystemCapability.Multimedia#MEDIA| 限定符和类型 | 类 | 说明 |
|---|---|---|
class |
AVController.PlayControls |
An inner class of
AVController to send media playback requests to the
AVSession and allow your application to send commands to the media
session. |
| 构造器 | 说明 |
|---|---|
AVController(Context context,
AVToken avToken) |
A constructor used to create an
AVController instance for your
application to control media playback. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
adjustAVPlaybackVolume(int direction,
int flags) |
Adjusts relative volume for the playback.
|
boolean |
dispatchAVKeyEvent(KeyEvent keyEvent) |
Dispatches a key event to the media session for the application to control
playback.
|
AVMetadata |
getAVMetadata() |
Obtains metadata of the media item.
|
AVPlaybackState |
getAVPlaybackState() |
Obtains the playback state.
|
List<AVQueueElement> |
getAVQueueElement() |
Obtains the playback queue.
|
CharSequence |
getAVQueueTitle() |
Obtains the title of the playback queue.
|
IntentAgent |
getAVSessionAbility() |
Obtains the
IntentAgent instance for
starting the user interface. |
PacMap |
getAVSessionInfo() |
Obtains additional information about the media session.
|
AVToken |
getAVToken() |
Obtains the token for your application to connect to the
AVSession
instance. |
long |
getFlags() |
Obtains flags for additional data of the
AVSession instance in which
the flags have been defined. |
PacMap |
getOptions() |
Obtains additional data of the
AVSession instance connected to this
AVController. |
AVController.PlayControls |
getPlayControls() |
Obtains a
PlayControls instance to control playback, for example, to
start or stop playback, or play the next item. |
String |
getSessionOwnerPackageName() |
Obtains the application bundle name in the
AVSession instance. |
boolean |
releaseAVControllerCallback(AVControllerCallback callback) |
Releases the callback set for the
AVSession instance. |
void |
sendCustomCommand(String command,
PacMap pacMap,
GeneralReceiver receiverCb) |
Sends a custom command from the application to the media session.
|
boolean |
setAVControllerCallback(AVControllerCallback callback) |
Registers a callback to receive changes, for example, of metadata and
playback states from a media session.
|
void |
setAVPlaybackVolume(int value,
int flags) |
Sets absolute volume for the playback.
|
static boolean |
setControllerForAbility(Ability ability,
AVController controller) |
Registers this
AVController with an
Ability to receive a key event. |
public static boolean setControllerForAbility(Ability ability, AVController controller)
AVController with an
Ability to receive a key event.ability - Indicates the ability to register the controller with.controller - Indicates the AVController instance to register.true if the registration is successful; returns
false otherwise.public boolean setAVControllerCallback(AVControllerCallback callback)
callback - Indicates the callback to implement for your application. For
available callbacks, see
AVControllerCallback.true if the registration is successful; returns
false otherwise.public boolean releaseAVControllerCallback(AVControllerCallback callback)
AVSession instance.callback - Indicates the callback to implement for your application. For
available callbacks, see
AVControllerCallback.true if the callback is released; returns
false otherwise.public List<AVQueueElement> getAVQueueElement()
public CharSequence getAVQueueTitle()
public AVPlaybackState getAVPlaybackState()
AVPlaybackStatepublic boolean dispatchAVKeyEvent(KeyEvent keyEvent)
keyEvent - Indicates the key event.true if the dispatch is successful; returns
false otherwise.public void sendCustomCommand(String command, PacMap pacMap, GeneralReceiver receiverCb)
You can refer to
AVSessionCallback.onCommand(java.lang.String, ohos.utils.PacMap, ohos.app.GeneralReceiver) to
specify the input parameters.
command - Indicates the command.pacMap - Indicates command parameters, which can be null.receiverCb - Indicates the callback that receives the execution result.
This parameter can be null.IllegalArgumentException - Throws this exception if the command is
null.public IntentAgent getAVSessionAbility()
IntentAgent instance for
starting the user interface.IntentAgent instance.public AVToken getAVToken()
AVSession
instance. This token is used to create an AVController instance.public void adjustAVPlaybackVolume(int direction,
int flags)
-110direction - Indicates the adjustment direction.flags - Indicates flags for additional information.public void setAVPlaybackVolume(int value,
int flags)
value - Indicates the playback volume to set to.flags - Indicates flags for additional information.public PacMap getOptions()
AVSession instance connected to this
AVController.AVSession instance.public long getFlags()
AVSession instance in which
the flags have been defined.public AVMetadata getAVMetadata()
AVMetadata instance.public String getSessionOwnerPackageName()
AVSession instance.public PacMap getAVSessionInfo()
public AVController.PlayControls getPlayControls()
PlayControls instance to control playback, for example, to
start or stop playback, or play the next item.PlayControls instance.