PrefetchingRepository

class PrefetchingRepository(val cachingRepository: MediaRepository, var disableEagerCaching: Boolean = false, val requestDispatcher: CoroutineDispatcher = Dispatchers.Main) : MediaRepository

This is a meta media repository that performs requests to all possible values of an item as soon as it gets an item it has not seen before. This can be used in combination with a caching repository to perform eager caching.

An exception to this are requests to getTimestampLink() since actual requests this is rare.

Parameters

cachingRepository

a MediaRepository implementation that performs caching

disableEagerCaching

this allows to temporarily disable eager requests. This can be uses when the system is in power saving mode.

requestDispatcher

the thread this repository should use to perform requests with. This should be the same thad as the one NewPlayer is in.

Constructors

Link copied to clipboard
constructor(cachingRepository: MediaRepository, disableEagerCaching: Boolean = false, requestDispatcher: CoroutineDispatcher = Dispatchers.Main)

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val requestDispatcher: CoroutineDispatcher
Link copied to clipboard
val requestScope: CoroutineScope

Functions

Link copied to clipboard
open suspend override fun getChapters(item: String): List<Chapter>

This should return the chapters associated with an item. If an item does not have chapters you may return an empty list.

Link copied to clipboard

Supply a custom HttpDataSource.Factory. This is important for Youtube.

Link copied to clipboard
open suspend override fun getMetaInfo(item: String): MediaMetadata

Get MediaMetadata information for a certain item. Please refer to the media3 documentation for MediaMetadata.

Link copied to clipboard
open suspend override fun getPreviewThumbnail(item: String, timestampInMs: Long): Bitmap?

This should return a thumbnail associated with the provided timestamp of the provided item. The reason this function does not simply return a Uri to a bitmap is that some platforms like Youtube provide the preview thumbnail as a collage of multiple thumbnails within one jpeg file. It is then the task of the client to crop this jpeg to only show the piece of that image that depicts the thumbnail for the given timestamp.

Link copied to clipboard

The amount of review thumbnails an item provides. This is used to tell async requesting tools how much requests to spawn to get all thumbnails. It's also used to calculate the correct keys for the caching repository.

Link copied to clipboard

Returns the information of the repository. Please see the documentation for RepoMetaInfo for more details.

Link copied to clipboard
open suspend override fun getStreams(item: String): List<Stream>

This should return all the Streams associated with an item.

Link copied to clipboard
open suspend override fun getSubtitles(item: String): List<Subtitle>

This should return all the Subtitles associated with an item.

Link copied to clipboard
open suspend override fun getTimestampLink(item: String, timestampInSeconds: Long): String

Should return the link to a certain timestamp of the video/audio stream associated by item. An example for a timestamp link would be this (don't watch it though its dangerous): https://www.youtube.com/watch?v=H8ZH_mkfPUY&t=19s

Link copied to clipboard
fun reset()

Resets the information weather something was seen before or not.