public final class AVSession extends Object
SystemCapability.Multimedia#MEDIA| 限定符和类型 | 字段 | 说明 |
|---|---|---|
static String |
ACTION_MEDIA_BUTTON |
|
static String |
PARAM_KEY_EVENT |
| 构造器 | 说明 |
|---|---|
AVSession(Context context,
String tag) |
A constructor used to create an
AVSession instance to control media playback. |
AVSession(Context context,
String tag,
PacMap sessionInfo) |
A constructor used to create an
AVSession instance with additional session information. |
| 限定符和类型 | 方法 | 说明 |
|---|---|---|
void |
enableAVSessionActive(boolean active) |
Sets whether to activate the media session.
|
AVController |
getAVController() |
Obtains the
AVController instance automatically created
when this AVSession instance was created. |
AVToken |
getAVToken() |
Obtains the token for your application to connect to this
AVSession instance. |
AVCallerUserInfo |
getCurrentControllerInfo() |
Obtains information about the
AVController instance sending the current request. |
boolean |
isAVSessionActive() |
Checks whether this
AVSession instance is activated. |
void |
release() |
Releases resources associated with this
AVSession instance. |
void |
sendAVSessionEvent(String event,
PacMap options) |
Sends a media session event to all
AVController instances listening for this AVSession instance. |
boolean |
setAVButtonReceiver(IntentAgent ia) |
Sets an
IntentAgent instance to receive the media button event for
restarting the application via a media button. |
void |
setAVMetadata(AVMetadata avMetadata) |
Sets metadata of a media item.
|
void |
setAVPlaybackState(AVPlaybackState state) |
Sets the current playback state.
|
void |
setAVQueue(List<AVQueueElement> queue) |
Sets a playback queue.
|
void |
setAVQueueTitle(CharSequence queueTitle) |
Sets a title for the playback queue, which will be displayed on a UI page.
|
void |
setAVRatingStyle(int ratingStyle) |
Sets the media rating system used for this
AVSession instance, which can be one of the following:
AVRATING_NONE
AVRATING_STYLE_HEART
AVRATING_STYLE_THUMB_UP_DOWN
AVRATING_STYLE_3_STARS
AVRATING_STYLE_4_STARS
AVRATING_STYLE_5_STARS
AVRATING_STYLE_PERCENTAGE
|
boolean |
setAVSessionAbility(IntentAgent ia) |
Sets an
IntentAgent instance for this AVSession to start a UI page. |
void |
setAVSessionCallback(AVSessionCallback callback) |
Sets a callback to control the player.
|
void |
setOptions(PacMap options) |
Sets additional information about this
AVSession. |
void |
useLocalAudioStreamProperty(AudioStreamProperty properties) |
Sets audio stream properties for this media session.
|
void |
useRemoteVolumeHandler(AVVolumeHandler volumeHandler) |
Sets a specific
AVVolumeHandler for volume control. |
public static final String ACTION_MEDIA_BUTTON
public static final String PARAM_KEY_EVENT
public AVSession(Context context, String tag)
AVSession instance to control media playback.context - Indicates the application context.tag - Indicates a short name (usually the application name) for debugging.public AVSession(Context context, String tag, PacMap sessionInfo)
AVSession instance with additional session information.context - Indicates the application context.tag - Indicates a short name (usually the application name) for debugging.sessionInfo - Indicates additional information about the media session.
The information includes the application version and a list of custom commands supported by the session.public void setAVSessionCallback(AVSessionCallback callback)
callback - Indicates the callback to implement for your application.
For available callbacks, see AVSessionCallback.
If this parameter is null, the control over the player will be ineffective.public boolean setAVSessionAbility(IntentAgent ia)
IntentAgent instance for this AVSession to start a UI page.ia - Indicates the IntentAgent instance for starting the UI page.true if the setting is successful; returns false otherwise.public boolean setAVButtonReceiver(IntentAgent ia)
IntentAgent instance to receive the media button event for
restarting the application via a media button.ia - Indicates the IntentAgent instance to receive the media button event.true if the setting is successful; returns false otherwise.public void enableAVSessionActive(boolean active)
true. If the session stops receiving a command, set the parameter to false.active - Specifies whether the media session will be activated. Value true indicates
that the session will be activated, and false indicates that the session will be deactivated.public boolean isAVSessionActive()
AVSession instance is activated.true if the session is activated; returns false otherwise.public void sendAVSessionEvent(String event, PacMap options)
AVController instances listening for this AVSession instance.event - Indicates the name of the event to send.options - Indicates additional information about the event.public void release()
AVSession instance.
You need to call this method after the application finishes playback.
public AVToken getAVToken()
AVSession instance.
This token is used to create an AVController instance.public AVController getAVController()
AVController instance automatically created
when this AVSession instance was created.AVController instance.public void setAVPlaybackState(AVPlaybackState state)
state - Indicates the AVPlaybackState instance
representing the current playback state.public void setAVMetadata(AVMetadata avMetadata)
avMetadata - Indicates the AVMetadata instance to set.public void setAVQueue(List<AVQueueElement> queue)
queue - Indicates the playback queue.public void setAVQueueTitle(CharSequence queueTitle)
queueTitle - Indicates the title to set.public void setAVRatingStyle(int ratingStyle)
AVSession instance, which can be one of the following:
ratingStyle - Indicates the media rating system to set.public void setOptions(PacMap options)
AVSession.options - Indicates additional session information.public void useRemoteVolumeHandler(AVVolumeHandler volumeHandler) throws IllegalArgumentException
AVVolumeHandler for volume control.
After this method is called, the system will not process volume adjustment requests for this media session.
volumeHandler - Indicates the AVVolumeHandler instance used to handle volume change events.IllegalArgumentException - Throws this exception if volumeHandler is null.useLocalAudioStreamProperty(AudioStreamProperty)public void useLocalAudioStreamProperty(AudioStreamProperty properties) throws IllegalArgumentException
After this method is called, volume adjustment requests sent to this media session will take effect on the audio streams with the properties you set.
properties - Indicates the audio stream properties to set.IllegalArgumentException - Throws this exception if properties is null.useRemoteVolumeHandler(AVVolumeHandler)public AVCallerUserInfo getCurrentControllerInfo()
AVController instance sending the current request.AVCallerUserInfo instance providing
information about the AVController.