The Android Developer Challenge is back! Submit your idea before December 2.

FileMediaItem

public class FileMediaItem
extends MediaItem

java.lang.Object
   ↳ androidx.media2.common.MediaItem
     ↳ androidx.media2.common.FileMediaItem


Structure for media item for a file.

Users should use FileMediaItem.Builder to create FileMediaItem.

You cannot directly send this object across the process through ParcelUtils. See MediaItem for detail.

See also:

Summary

Nested classes

class FileMediaItem.Builder

This Builder class simplifies the creation of a FileMediaItem object. 

Constants

long FD_LENGTH_UNKNOWN

Used when the length of file descriptor is unknown.

Inherited constants

Public methods

long getFileDescriptorLength()

Returns the content length associated with the ParcelFileDescriptor of this media item.

long getFileDescriptorOffset()

Returns the offset associated with the ParcelFileDescriptor of this media item.

ParcelFileDescriptor getParcelFileDescriptor()

Returns the ParcelFileDescriptor of this media item.

Inherited methods

Constants

FD_LENGTH_UNKNOWN

public static final long FD_LENGTH_UNKNOWN

Used when the length of file descriptor is unknown.

Constant Value: 576460752303423487 (0x07ffffffffffffff)

Public methods

getFileDescriptorLength

public long getFileDescriptorLength ()

Returns the content length associated with the ParcelFileDescriptor of this media item. FD_LENGTH_UNKNOWN means same as the length of source content.

Returns
long the content length associated with the ParcelFileDescriptor of this media item

getFileDescriptorOffset

public long getFileDescriptorOffset ()

Returns the offset associated with the ParcelFileDescriptor of this media item. It's meaningful only when it has been set by the MediaItem.Builder.

Returns
long the offset associated with the ParcelFileDescriptor of this media item

getParcelFileDescriptor

public ParcelFileDescriptor getParcelFileDescriptor ()

Returns the ParcelFileDescriptor of this media item.

Returns
ParcelFileDescriptor the ParcelFileDescriptor of this media item