MediaItem
public
class
MediaItem
extends Object
implements
VersionedParcelable
java.lang.Object | |
↳ | androidx.media2.common.MediaItem |
A class with information on a single media item with the metadata information. Here are use cases.
- Specify media items to
SessionPlayer
for playback. - Share media items across the processes.
Subclasses of the session player may only accept certain subclasses of the media items. Check the player documentation that you're interested in.
When it's shared across the processes, we cannot guarantee that they contain the right values because media items are application dependent especially for the metadata.
When an object of the MediaItem
's subclass is sent across the process between
MediaSession
/MediaController
or
MediaLibraryService.MediaLibrarySession
/
MediaBrowser
, the
object will sent as if it's MediaItem
. The recipient cannot get the object with the
subclasses' type. This will sanitize process specific information (e.g.
FileDescriptor
, Context
, etc).
This object is thread safe.
Summary
Nested classes | |
---|---|
class |
MediaItem.Builder
Builder for |
Constants | |
---|---|
long |
POSITION_UNKNOWN
Used when a position is unknown. |
Public methods | |
---|---|
long
|
getEndPosition()
Return the position in milliseconds at which the playback will end. |
MediaMetadata
|
getMetadata()
Gets the metadata of the media. |
long
|
getStartPosition()
Return the position in milliseconds at which the playback will start. |
void
|
setMetadata(MediaMetadata metadata)
Sets metadata. |
String
|
toString()
|
Inherited methods | |
---|---|
Constants
POSITION_UNKNOWN
public static final long POSITION_UNKNOWN
Used when a position is unknown.
See also:
Constant Value: 576460752303423487 (0x07ffffffffffffff)
Public methods
getEndPosition
public long getEndPosition ()
Return the position in milliseconds at which the playback will end.
POSITION_UNKNOWN
means ending at the end of source content.
Returns | |
---|---|
long |
the position in milliseconds at which the playback will end |
getMetadata
public MediaMetadata getMetadata ()
Gets the metadata of the media.
Returns | |
---|---|
MediaMetadata |
metadata from the session |
getStartPosition
public long getStartPosition ()
Return the position in milliseconds at which the playback will start.
Returns | |
---|---|
long |
the position in milliseconds at which the playback will start |
setMetadata
public void setMetadata (MediaMetadata metadata)
Sets metadata. If the metadata is not null
, its id should be matched with this
instance's media id.
Parameters | |
---|---|
metadata |
MediaMetadata : metadata to update |
See also:
toString
public String toString ()
Returns | |
---|---|
String |
Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-09-30 UTC.