MediaPlaybackViewModel
View model for playback information about the media currently being played, such as duration, elapsed time, title, artist, album, etc.
If the animations are disabled, for example to run instrumented tests, the progress will not be smoothly updated. progress can still be used in a TtSmoothProgressBar or TtSmoothSeekBar.
Note: When playback is active, all instances of MediaPlaybackViewModel with observed LiveData values will have a running timer to keep the MediaPlaybackParameters.timeInfo data up to date: unused instances should be destroyed.
Constructors
Properties
The active queue of media items.
The IviMediaItem.album of the current MediaPlaybackParameters.activeMediaItem if available, otherwise null
.
The art of the current MediaPlaybackParameters.activeMediaItem. If IviMediaItem.artUri is set to null
, a placeholder will be shown after a delay.
The IviMediaItem.artist of the current MediaPlaybackParameters.activeMediaItem if available, otherwise null
.
The duration of the current MediaPlaybackParameters.activeMediaItem. Duration.ZERO if there is no valid MediaPlaybackParameters.timeInfo set.
The elapsed time of the current MediaPlaybackParameters.activeMediaItem. null
if there is no valid MediaPlaybackParameters.timeInfo set.
The icon art of the current MediaPlaybackParameters.activeMediaItem. This typically looks like art, but smaller. If IviMediaItem.iconArtUri is set to null
, a placeholder will be shown after a delay.
Whether the artwork support to be scaled up to a larger size. This depends on the source artwork image resolution. See SourceDefinitionPolicy.isArtworkUpscalingSupported.
Whether playback is currently buffering, meaning it is intending to play but still waiting for the data to arrive.
The primary text of the current MediaPlaybackParameters.activeMediaItem or MediaPlaybackParameters.activeSource.
The progress information of the current MediaPlaybackParameters.activeMediaItem. It is updated automatically while media is playing.
The remaining time of the current MediaPlaybackParameters.activeMediaItem. null
if there is no valid MediaPlaybackParameters.timeInfo set.
The secondary text of the current MediaPlaybackParameters.activeMediaItem. It contains less relevant information, such as a subtitle or an artist name, depending on which metadata is available.
The currently active source icon. If there is no active source, the value is set to null
. If there is an active source, the value depends on the provided SourceAttributionFormat and the source's MediaSourceAttributionPolicy.getLogo.
The currently active source name. If there is no active source, the value is set to StringsR.string.ttivi_media_source_invalid. If there is an active source, the value depends on the provided SourceAttributionFormat and the source's MediaSourceAttributionPolicy.getName.
A touch track controller used for seeking a position in the current MediaPlaybackParameters.activeMediaItem, when the seek action is supported. This can be used with a TtSmoothSeekBar to seek to a specific position by dragging the UI control.