Google은 흑인 공동체를 위한 인종 간 평등을 진전시키기 위해 노력하고 있습니다. Google에서 어떤 노력을 하고 있는지 확인하세요.

MediaControllerCompat

class MediaControllerCompat
kotlin.Any
   ↳ android.support.v4.media.session.MediaControllerCompat

Allows an app to interact with an ongoing media session. Media buttons and other commands can be sent to the session. A callback may be registered to receive updates from the session, such as metadata and play state changes.

A MediaController can be created if you have a MediaSessionCompat.Token from the session owner.

MediaController objects are thread-safe.

This is a helper for accessing features in android.media.session.MediaSession introduced after API level 4 in a backwards compatible fashion.

If MediaControllerCompat is created with a session token from another process, following methods will not work directly after the creation if the session token is not passed through a MediaBrowserCompat:

Summary

Nested classes

abstract

Callback for receiving updates on from the session.

Holds information about the way volume is handled for this session.

abstract

Interface for controlling media playback on a session.

Public constructors

<init>(context: Context!, @NonNull session: MediaSessionCompat)

Creates a media controller from a session.

<init>(context: Context!, @NonNull sessionToken: MediaSessionCompat.Token)

Creates a media controller from a session token which may have been obtained from another process.

Public methods

Unit

Adds a queue item from the given description at the end of the play queue of this session.

Unit
addQueueItem(description: MediaDescriptionCompat!, index: Int)

Adds a queue item from the given description at the specified position in the play queue of this session.

Unit
adjustVolume(direction: Int, flags: Int)

Adjusts the volume of the output this session is playing on.

Boolean

Sends the specified media button event to the session.

Bundle!

Gets the extras for this session.

Long

Gets the flags for this session.

Any!

Gets the underlying framework android.media.session.MediaController object.

static MediaControllerCompat!
getMediaController(@NonNull activity: Activity)

Retrieves the MediaControllerCompat set in the activity by setMediaController(Activity, MediaControllerCompat) for sending media key and volume events.

MediaMetadataCompat!

Gets the current metadata for this session.

String!

Gets the session owner's package name.

MediaControllerCompat.PlaybackInfo!

Gets the current playback info for this session.

PlaybackStateCompat!

Gets the current playback state for this session.

MutableList<MediaSessionCompat.QueueItem!>!

Gets the current play queue for this session if one is set.

CharSequence!

Gets the queue title for this session.

Int

Gets the rating type supported by the session.

Int

Gets the repeat mode for this session.

PendingIntent!

Gets an intent for launching UI associated with this session if one exists.

MediaSessionCompat.Token!

Gets the token for the session that this controller is connected to.

Int

Gets the shuffle mode for this session.

MediaControllerCompat.TransportControls!

Gets a TransportControls instance for this session.

Boolean

Returns whether captioning is enabled for this session.

Boolean

Returns whether the session is ready or not.

Unit

Adds a callback to receive updates from the Session.

Unit

Adds a callback to receive updates from the session.

Unit

Removes the first occurrence of the specified MediaSessionCompat.QueueItem with the given description in the play queue of the associated session.

Unit

Removes an queue item at the specified position in the play queue of this session.

Unit
sendCommand(@NonNull command: String, @Nullable params: Bundle?, @Nullable cb: ResultReceiver?)

Sends a generic command to the session.

static Unit
setMediaController(@NonNull activity: Activity, mediaController: MediaControllerCompat!)

Sets a MediaControllerCompat in the activity for later retrieval via getMediaController(Activity).

Unit
setVolumeTo(value: Int, flags: Int)

Sets the volume of the output this session is playing on.

Unit

Stops receiving updates on the specified callback.

Public constructors

<init>

MediaControllerCompat(context: Context!, @NonNull session: MediaSessionCompat)

Creates a media controller from a session.

Parameters
session Context!: The session to be controlled.

<init>

MediaControllerCompat(context: Context!, @NonNull sessionToken: MediaSessionCompat.Token)

Creates a media controller from a session token which may have been obtained from another process.

Parameters
sessionToken Context!: The token of the session to be controlled.
Exceptions
RemoteException if the session is not accessible.

Public methods

addQueueItem

fun addQueueItem(description: MediaDescriptionCompat!): Unit

Adds a queue item from the given description at the end of the play queue of this session. Not all sessions may support this. To know whether the session supports this, get the session's flags with getFlags() and check that the flag MediaSessionCompat#FLAG_HANDLES_QUEUE_COMMANDS is set.

Parameters
description MediaDescriptionCompat!: The MediaDescriptionCompat for creating the MediaSessionCompat.QueueItem to be inserted.
Exceptions
UnsupportedOperationException If this session doesn't support this.

addQueueItem

fun addQueueItem(description: MediaDescriptionCompat!, index: Int): Unit

Adds a queue item from the given description at the specified position in the play queue of this session. Shifts the queue item currently at that position (if any) and any subsequent queue items to the right (adds one to their indices). Not all sessions may support this. To know whether the session supports this, get the session's flags with getFlags() and check that the flag MediaSessionCompat#FLAG_HANDLES_QUEUE_COMMANDS is set.

Parameters
description MediaDescriptionCompat!: The MediaDescriptionCompat for creating the MediaSessionCompat.QueueItem to be inserted.
index MediaDescriptionCompat!: The index at which the created MediaSessionCompat.QueueItem is to be inserted.
Exceptions
UnsupportedOperationException If this session doesn't support this.

adjustVolume

fun adjustVolume(direction: Int, flags: Int): Unit

Adjusts the volume of the output this session is playing on. The direction must be one of