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

FileMediaItem

open class FileMediaItem : MediaItem
androidx.media2.common.MediaItem
   ↳ androidx.media2.common.FileMediaItem

Structure for media item for a file.

Users should use Builder to create FileMediaItem.

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

Summary

Nested classes

This Builder class simplifies the creation of a FileMediaItem object.

Constants

static Long

Used when the length of file descriptor is unknown.

Inherited constants

Public methods

open Long

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

open Long

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

open ParcelFileDescriptor

Returns the ParcelFileDescriptor of this media item.

Inherited functions

Constants

FD_LENGTH_UNKNOWN

static val FD_LENGTH_UNKNOWN: Long

Used when the length of file descriptor is unknown.

Value: LONG_MAX

Public methods

getFileDescriptorLength

open fun getFileDescriptorLength(): Long

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

Return
Long: the content length associated with the ParcelFileDescriptor of this media item

getFileDescriptorOffset

open fun getFileDescriptorOffset(): Long

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

Return
Long: the offset associated with the ParcelFileDescriptor of this media item

getParcelFileDescriptor

@NonNull open fun getParcelFileDescriptor(): ParcelFileDescriptor

Returns the ParcelFileDescriptor of this media item.

Return
ParcelFileDescriptor: the ParcelFileDescriptor of this media item