MediaMetadata.Builder
public final class MediaMetadata.Builder
A builder for MediaMetadata instances.
Summary
Public constructors |
|---|
Builder() |
Public constructors
Public methods
build
public MediaMetadata build()
Returns a new MediaMetadata instance with the current builder values.
maybeSetArtworkData
@CanIgnoreReturnValue
public MediaMetadata.Builder maybeSetArtworkData(
byte[] artworkData,
@MediaMetadata.PictureType int artworkDataType
)
Sets the artwork data as a compressed byte array in the event that the associated PictureType 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
public MediaMetadata.Builder populate(@Nullable MediaMetadata mediaMetadata)
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
public MediaMetadata.Builder populateFromMetadata(List<Metadata> metadataList)
Sets all fields supported by the entries within the list of Metadata.
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 Metadata relate to the same MediaMetadata field, then the last one will be used.
populateFromMetadata
@CanIgnoreReturnValue
@UnstableApi
public MediaMetadata.Builder populateFromMetadata(Metadata metadata)
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
public MediaMetadata.Builder setAlbumArtist(@Nullable CharSequence albumArtist)
Sets the album artist.
setAlbumTitle
@CanIgnoreReturnValue
public MediaMetadata.Builder setAlbumTitle(@Nullable CharSequence albumTitle)
Sets the album title.
setArtist
@CanIgnoreReturnValue
public MediaMetadata.Builder setArtist(@Nullable CharSequence artist)
Sets the artist.
setArtworkData
@CanIgnoreReturnValue
@UnstableApi
public MediaMetadata.BuildersetArtworkData(@Nullable byte[] artworkData)
setArtworkData
@CanIgnoreReturnValue
public MediaMetadata.Builder setArtworkData(
@Nullable byte[] artworkData,
@MediaMetadata.PictureType @Nullable @MediaMetadata.PictureType Integer artworkDataType
)
Sets the artwork data as a compressed byte array with an associated artworkDataType.
setArtworkUri
@CanIgnoreReturnValue
public MediaMetadata.Builder setArtworkUri(@Nullable Uri artworkUri)
Sets the artwork Uri.
setAuthor
@CanIgnoreReturnValue
@UnstableApi
public MediaMetadata.Builder setAuthor(@Nullable CharSequence author)
Sets the author.
setCompilation
@CanIgnoreReturnValue
public MediaMetadata.Builder setCompilation(@Nullable CharSequence compilation)
Sets the compilation.
setComposer
@CanIgnoreReturnValue
public MediaMetadata.Builder setComposer(@Nullable CharSequence composer)
Sets the composer.
setConductor
@CanIgnoreReturnValue
public MediaMetadata.Builder setConductor(@Nullable CharSequence conductor)
Sets the conductor.
setDescription
@CanIgnoreReturnValue
public MediaMetadata.Builder setDescription(@Nullable CharSequence description)
Sets the description.
setDiscNumber
@CanIgnoreReturnValue
public MediaMetadata.Builder setDiscNumber(@Nullable Integer discNumber)
Sets the disc number.
setDiscSubtitle
@UnstableApi
@CanIgnoreReturnValue
public MediaMetadata.Builder setDiscSubtitle(@Nullable CharSequence discSubtitle)
Sets the disc subtitle.
setDisplayTitle
@CanIgnoreReturnValue
public MediaMetadata.Builder setDisplayTitle(@Nullable CharSequence displayTitle)
Sets the display title.
setDurationMs
@CanIgnoreReturnValue
public MediaMetadata.Builder setDurationMs(@Nullable Long durationMs)
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
public MediaMetadata.Builder setExtras(@Nullable Bundle extras)
Sets the extras Bundle.
setFolderType
@CanIgnoreReturnValue
public MediaMetadata.BuildersetFolderType(
@MediaMetadata.FolderType @Nullable @MediaMetadata.FolderType Integer folderType
)
Sets the FolderType.
setGenre
@CanIgnoreReturnValue
public MediaMetadata.Builder setGenre(@Nullable CharSequence genre)
Sets the genre.
setIsBrowsable
@CanIgnoreReturnValue
public MediaMetadata.Builder setIsBrowsable(@Nullable Boolean isBrowsable)
Sets whether the media is a browsable folder.
setIsPlayable
@CanIgnoreReturnValue
public MediaMetadata.Builder setIsPlayable(@Nullable Boolean isPlayable)
Sets whether the media is playable.
setMediaType
@CanIgnoreReturnValue
public MediaMetadata.Builder setMediaType(
@MediaMetadata.MediaType @Nullable @MediaMetadata.MediaType Integer mediaType
)
Sets the MediaType.
setOverallRating
@CanIgnoreReturnValue
public MediaMetadata.Builder setOverallRating(@Nullable Rating overallRating)
Sets the overall Rating.
setRecordingDay
@CanIgnoreReturnValue
public MediaMetadata.Builder setRecordingDay(@Nullable @IntRange(from = 1, to = 31) Integer recordingDay)
Sets the day of the recording date.
Value should be between 1 and 31.
setRecordingMonth
@CanIgnoreReturnValue
public MediaMetadata.Builder setRecordingMonth(
@Nullable @IntRange(from = 1, to = 12) Integer recordingMonth
)
Sets the month of the recording date.
Value should be between 1 and 12.
setRecordingYear
@CanIgnoreReturnValue
public MediaMetadata.Builder setRecordingYear(@Nullable Integer recordingYear)
Sets the year of the recording date.
setReleaseDay
@CanIgnoreReturnValue
public MediaMetadata.Builder setReleaseDay(@Nullable @IntRange(from = 1, to = 31) Integer releaseDay)
Sets the day of the release date.
Value should be between 1 and 31.
setReleaseMonth
@CanIgnoreReturnValue
public MediaMetadata.Builder setReleaseMonth(@Nullable @IntRange(from = 1, to = 12) Integer releaseMonth)
Sets the month of the release date.
Value should be between 1 and 12.
setReleaseYear
@CanIgnoreReturnValue
public MediaMetadata.Builder setReleaseYear(@Nullable Integer releaseYear)
Sets the year of the release date.
setStation
@CanIgnoreReturnValue
public MediaMetadata.Builder setStation(@Nullable CharSequence station)
Sets the name of the station streaming the media.
setSubtitle
@CanIgnoreReturnValue
public MediaMetadata.Builder setSubtitle(@Nullable CharSequence subtitle)
Sets the subtitle.
This is the secondary title of the media, unrelated to closed captions.
setSupportedCommands
@CanIgnoreReturnValue
@UnstableApi
public MediaMetadata.Builder setSupportedCommands(List<String> supportedCommands)
Sets the IDs of the supported commands (see for instance
CommandButton.sessionCommand.customAction of the Media3 session module).
setTitle
@CanIgnoreReturnValue
public MediaMetadata.Builder setTitle(@Nullable CharSequence title)
Sets the title.
setTotalDiscCount
@CanIgnoreReturnValue
public MediaMetadata.Builder setTotalDiscCount(@Nullable Integer totalDiscCount)
Sets the total number of discs.
setTotalTrackCount
@CanIgnoreReturnValue
public MediaMetadata.Builder setTotalTrackCount(@Nullable Integer totalTrackCount)
Sets the total number of tracks.
setTrackNumber
@CanIgnoreReturnValue
public MediaMetadata.Builder setTrackNumber(@Nullable Integer trackNumber)
Sets the track number.
setUserRating
@CanIgnoreReturnValue
public MediaMetadata.Builder setUserRating(@Nullable Rating userRating)
Sets the user Rating.
setWriter
@CanIgnoreReturnValue
public MediaMetadata.Builder setWriter(@Nullable CharSequence writer)
Sets the writer.
setYear
@CanIgnoreReturnValue
@UnstableApi
public MediaMetadata.BuildersetYear(@Nullable Integer year)