Save the date! Android Dev Summit is coming to Sunnyvale, CA on Oct 23-24, 2019.

FileMediaItem

public class FileMediaItem
extends MediaItem

java.lang.Object
   ↳ androidx.media2.MediaItem
     ↳ androidx.media2.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

FileDescriptor getFileDescriptor()

Return the FileDescriptor of this media item.

long getFileDescriptorLength()

Return the content length associated with the FileDescriptor of this media item.

long getFileDescriptorOffset()

Return the offset associated with the FileDescriptor 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

getFileDescriptor

public FileDescriptor getFileDescriptor ()

Return the FileDescriptor of this media item.

Returns
FileDescriptor the FileDescriptor of this media item

getFileDescriptorLength

public long getFileDescriptorLength ()

Return the content length associated with the FileDescriptor of this media item. FD_LENGTH_UNKNOWN means same as the length of source content.

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

getFileDescriptorOffset

public long getFileDescriptorOffset ()

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

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