MediaMetadata.Builder


class MediaMetadata.Builder


A builder for MediaMetadata instances.

Summary

Public constructors

Public functions

MediaMetadata!

Returns a new MediaMetadata instance with the current builder values.

MediaMetadata.Builder!
@CanIgnoreReturnValue
maybeSetArtworkData(
    artworkData: ByteArray!,
    @MediaMetadata.PictureType artworkDataType: Int
)

Sets the artwork data as a compressed byte array in the event that the associated is PICTURE_TYPE_FRONT_COVER, the existing PictureType is not PICTURE_TYPE_FRONT_COVER, or the current artworkData is not set.

MediaMetadata.Builder!

Populates all the fields from mediaMetadata.

MediaMetadata.Builder!

Sets all fields supported by the entries within the list of .

MediaMetadata.Builder!

Sets all fields supported by the entries within the Metadata.

MediaMetadata.Builder!

Sets the album artist.

MediaMetadata.Builder!

Sets the album title.

MediaMetadata.Builder!

Sets the artist.

MediaMetadata.Builder!

This function is deprecated.

Use setArtworkData or maybeSetArtworkData, providing a PictureType.

MediaMetadata.Builder!

Sets the artwork data as a compressed byte array with an associated artworkDataType.

MediaMetadata.Builder!

Sets the artwork Uri.

MediaMetadata.Builder!

Sets the compilation.

MediaMetadata.Builder!

Sets the composer.

MediaMetadata.Builder!

Sets the conductor.

MediaMetadata.Builder!

Sets the description.

MediaMetadata.Builder!

Sets the disc number.

MediaMetadata.Builder!

Sets the display title.

MediaMetadata.Builder!

Sets the optional duration, non-negative and in milliseconds.

MediaMetadata.Builder!

Sets the extras Bundle.

MediaMetadata.Builder!

This function is deprecated.

Use setIsBrowsable to indicate if an item is a browsable folder and use setMediaType to indicate the type of the folder.

MediaMetadata.Builder!

Sets the genre.

MediaMetadata.Builder!

Sets whether the media is a browsable folder.

MediaMetadata.Builder!

Sets whether the media is playable.

MediaMetadata.Builder!

Sets the MediaType.

MediaMetadata.Builder!

Sets the overall Rating.

MediaMetadata.Builder!
@CanIgnoreReturnValue
setRecordingDay(recordingDay: @IntRange(from = 1, to = 31) Int?)

Sets the day of the recording date.

MediaMetadata.Builder!
@CanIgnoreReturnValue
setRecordingMonth(recordingMonth: @IntRange(from = 1, to = 12) Int?)

Sets the month of the recording date.

MediaMetadata.Builder!

Sets the year of the recording date.

MediaMetadata.Builder!
@CanIgnoreReturnValue
setReleaseDay(releaseDay: @IntRange(from = 1, to = 31) Int?)

Sets the day of the release date.

MediaMetadata.Builder!
@CanIgnoreReturnValue
setReleaseMonth(releaseMonth: @IntRange(from = 1, to = 12) Int?)

Sets the month of the release date.

MediaMetadata.Builder!

Sets the year of the release date.

MediaMetadata.Builder!

Sets the name of the station streaming the media.

MediaMetadata.Builder!

Sets the subtitle.

MediaMetadata.Builder!

Sets the IDs of the supported commands (see for instance CommandButton.sessionCommand.customAction of the Media3 session module).

MediaMetadata.Builder!

Sets the title.

MediaMetadata.Builder!

Sets the total number of discs.

MediaMetadata.Builder!

Sets the total number of tracks.

MediaMetadata.Builder!

Sets the track number.

MediaMetadata.Builder!

Sets the user Rating.

MediaMetadata.Builder!

Sets the writer.

MediaMetadata.Builder!

This function is deprecated.

Use setRecordingYear instead.

Public constructors

Builder

Builder()

Public functions

build

fun build(): MediaMetadata!

Returns a new MediaMetadata instance with the current builder values.

maybeSetArtworkData

@CanIgnoreReturnValue
fun maybeSetArtworkData(
    artworkData: ByteArray!,
    @MediaMetadata.PictureType artworkDataType: Int
): MediaMetadata.Builder!

Sets the artwork data as a compressed byte array in the event that the associated is PICTURE_TYPE_FRONT_COVER, the existing PictureType is not PICTURE_TYPE_FRONT_COVER, or the current artworkData is not set.

Use setArtworkData to set the artwork data without checking the PictureType.

populate

@CanIgnoreReturnValue
@UnstableApi
fun populate(mediaMetadata: MediaMetadata?): MediaMetadata.Builder!

Populates all the fields from mediaMetadata.

Fields are populated when they are non-null with an exception that both artworkUri and artworkData are populated, when at least one of them is non-null.

populateFromMetadata

@CanIgnoreReturnValue
@UnstableApi
fun populateFromMetadata(metadataList: (Mutable)List<Metadata!>!): MediaMetadata.Builder!

Sets all fields supported by the entries within the list of .

Fields are only set if the Metadata.Entry has an implementation for populateMediaMetadata.

In the event that multiple Metadata.Entry objects within any of the relate to the same MediaMetadata field, then the last one will be used.

populateFromMetadata

@CanIgnoreReturnValue
@UnstableApi
fun populateFromMetadata(metadata: Metadata!): MediaMetadata.Builder!

Sets all fields supported by the entries within the Metadata.

Fields are only set if the Metadata.Entry has an implementation for populateMediaMetadata.

In the event that multiple Metadata.Entry objects within the Metadata relate to the same MediaMetadata field, then the last one will be used.

setAlbumArtist

@CanIgnoreReturnValue
fun setAlbumArtist(albumArtist: CharSequence?): MediaMetadata.Builder!

Sets the album artist.

setAlbumTitle

@CanIgnoreReturnValue
fun setAlbumTitle(albumTitle: CharSequence?): MediaMetadata.Builder!

Sets the album title.

setArtist

@CanIgnoreReturnValue
fun setArtist(artist: CharSequence?): MediaMetadata.Builder!

Sets the artist.

setArtworkData

@CanIgnoreReturnValue
@UnstableApi
fun setArtworkData(artworkData: ByteArray?): MediaMetadata.Builder!

setArtworkData

@CanIgnoreReturnValue
fun setArtworkData(
    artworkData: ByteArray?,
    @MediaMetadata.PictureType artworkDataType: @MediaMetadata.PictureType Int?
): MediaMetadata.Builder!

Sets the artwork data as a compressed byte array with an associated artworkDataType.

setArtworkUri

@CanIgnoreReturnValue
fun setArtworkUri(artworkUri: Uri?): MediaMetadata.Builder!

Sets the artwork Uri.

setCompilation

@CanIgnoreReturnValue
fun setCompilation(compilation: CharSequence?): MediaMetadata.Builder!

Sets the compilation.

setComposer

@CanIgnoreReturnValue
fun setComposer(composer: CharSequence?): MediaMetadata.Builder!

Sets the composer.

setConductor

@CanIgnoreReturnValue
fun setConductor(conductor: CharSequence?): MediaMetadata.Builder!

Sets the conductor.

setDescription

@CanIgnoreReturnValue
fun setDescription(description: CharSequence?): MediaMetadata.Builder!

Sets the description.

setDiscNumber

@CanIgnoreReturnValue
fun setDiscNumber(discNumber: Int?): MediaMetadata.Builder!

Sets the disc number.

setDisplayTitle

@CanIgnoreReturnValue
fun setDisplayTitle(displayTitle: CharSequence?): MediaMetadata.Builder!

Sets the display title.

setDurationMs

@UnstableApi
@CanIgnoreReturnValue
fun setDurationMs(durationMs: Long?): MediaMetadata.Builder!

Sets the optional duration, non-negative and in milliseconds.

The duration is populated by the app when building the metadata object and is for informational purpose only. For retrieving the duration of the media item currently being played, use getDuration instead.

Throws
java.lang.IllegalArgumentException

if the duration is negative.

setExtras

@CanIgnoreReturnValue
fun setExtras(extras: Bundle?): MediaMetadata.Builder!

Sets the extras Bundle.

setFolderType

@CanIgnoreReturnValue
fun setFolderType(
    @MediaMetadata.FolderType folderType: @MediaMetadata.FolderType Int?
): MediaMetadata.Builder!

Sets the FolderType.

setGenre

@CanIgnoreReturnValue
fun setGenre(genre: CharSequence?): MediaMetadata.Builder!

Sets the genre.

setIsBrowsable

@CanIgnoreReturnValue
fun setIsBrowsable(isBrowsable: Boolean?): MediaMetadata.Builder!

Sets whether the media is a browsable folder.

setIsPlayable

@CanIgnoreReturnValue
fun setIsPlayable(isPlayable: Boolean?): MediaMetadata.Builder!

Sets whether the media is playable.

setOverallRating

@CanIgnoreReturnValue
fun setOverallRating(overallRating: Rating?): MediaMetadata.Builder!

Sets the overall Rating.

setRecordingDay

@CanIgnoreReturnValue
fun setRecordingDay(recordingDay: @IntRange(from = 1, to = 31) Int?): MediaMetadata.Builder!

Sets the day of the recording date.

Value should be between 1 and 31.

setRecordingMonth

@CanIgnoreReturnValue
fun setRecordingMonth(recordingMonth: @IntRange(from = 1, to = 12) Int?): MediaMetadata.Builder!

Sets the month of the recording date.

Value should be between 1 and 12.

setRecordingYear

@CanIgnoreReturnValue
fun setRecordingYear(recordingYear: Int?): MediaMetadata.Builder!

Sets the year of the recording date.

setReleaseDay

@CanIgnoreReturnValue
fun setReleaseDay(releaseDay: @IntRange(from = 1, to = 31) Int?): MediaMetadata.Builder!

Sets the day of the release date.

Value should be between 1 and 31.

setReleaseMonth

@CanIgnoreReturnValue
fun setReleaseMonth(releaseMonth: @IntRange(from = 1, to = 12) Int?): MediaMetadata.Builder!

Sets the month of the release date.

Value should be between 1 and 12.

setReleaseYear

@CanIgnoreReturnValue
fun setReleaseYear(releaseYear: Int?): MediaMetadata.Builder!

Sets the year of the release date.

setStation

@CanIgnoreReturnValue
fun setStation(station: CharSequence?): MediaMetadata.Builder!

Sets the name of the station streaming the media.

setSubtitle

@CanIgnoreReturnValue
fun setSubtitle(subtitle: CharSequence?): MediaMetadata.Builder!

Sets the subtitle.

This is the secondary title of the media, unrelated to closed captions.

setSupportedCommands

@CanIgnoreReturnValue
@UnstableApi
fun setSupportedCommands(supportedCommands: (Mutable)List<String!>!): MediaMetadata.Builder!

Sets the IDs of the supported commands (see for instance CommandButton.sessionCommand.customAction of the Media3 session module).

setTitle

@CanIgnoreReturnValue
fun setTitle(title: CharSequence?): MediaMetadata.Builder!

Sets the title.

setTotalDiscCount

@CanIgnoreReturnValue
fun setTotalDiscCount(totalDiscCount: Int?): MediaMetadata.Builder!

Sets the total number of discs.

setTotalTrackCount

@CanIgnoreReturnValue
fun setTotalTrackCount(totalTrackCount: Int?): MediaMetadata.Builder!

Sets the total number of tracks.

setTrackNumber

@CanIgnoreReturnValue
fun setTrackNumber(trackNumber: Int?): MediaMetadata.Builder!

Sets the track number.

setUserRating

@CanIgnoreReturnValue
fun setUserRating(userRating: Rating?): MediaMetadata.Builder!

Sets the user Rating.

setWriter

@CanIgnoreReturnValue
fun setWriter(writer: CharSequence?): MediaMetadata.Builder!

Sets the writer.

setYear

@CanIgnoreReturnValue
@UnstableApi
fun setYear(year: Int?): MediaMetadata.Builder!