MediaPlaybackViewModel

@IviExperimental(reasons = [])
class MediaPlaybackViewModel(mediaConfiguration: MediaConfiguration, mediaPlaybackParameters: MediaPlaybackParameters, viewModelCoroutineScope: CoroutineScope, sourceAttributionFormat: SourceAttributionFormat = SourceAttributionFormat())

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

Link copied to clipboard
constructor(mediaConfiguration: MediaConfiguration, mediaPlaybackParameters: MediaPlaybackParameters, viewModelCoroutineScope: CoroutineScope, sourceAttributionFormat: SourceAttributionFormat = SourceAttributionFormat())

Properties

Link copied to clipboard

The active queue of media items.

Link copied to clipboard
val album: LiveData<StringResolver?>

The IviMediaItem.album of the current MediaPlaybackParameters.activeMediaItem if available, otherwise null.

Link copied to clipboard
val art: LiveData<RemoteImage>

The art of the current MediaPlaybackParameters.activeMediaItem. If IviMediaItem.artUri is set to null, a placeholder will be shown after a delay.

Link copied to clipboard
val artist: LiveData<StringResolver?>

The IviMediaItem.artist of the current MediaPlaybackParameters.activeMediaItem if available, otherwise null.

Link copied to clipboard
Link copied to clipboard

The elapsed time of the current MediaPlaybackParameters.activeMediaItem. null if there is no valid MediaPlaybackParameters.timeInfo set.

Link copied to clipboard
val iconArt: LiveData<RemoteImage>

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.

Link copied to clipboard

Whether playback is currently buffering, meaning it is intending to play but still waiting for the data to arrive.

Link copied to clipboard
Link copied to clipboard
val progress: LiveData<TimeTransition>

The progress information of the current MediaPlaybackParameters.activeMediaItem. It is updated automatically while media is playing.

Link copied to clipboard

The remaining time of the current MediaPlaybackParameters.activeMediaItem. null if there is no valid MediaPlaybackParameters.timeInfo set.

Link copied to clipboard
val secondaryText: LiveData<StringResolver?>

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.

Link copied to clipboard
val sourceIcon: LiveData<DrawableResolver?>

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.

Link copied to clipboard
val sourceName: LiveData<StringResolver>

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.

Link copied to clipboard

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.