Package com.castlabs.sdk.thumbs
Class LoadingStrategy.Builder
java.lang.Object
com.castlabs.sdk.thumbs.LoadingStrategy.Builder
- Enclosing class:
LoadingStrategy
Builder for
LoadingStrategy
. Waves can be added to the Strategy by chaining the
addXWave methods. Note that order *is* important. Waves will be processed sequentially
in adding order.
The waves should be added in ascending order of density. For instance, adding a
TimeWave
of 1 minute followed by another of 10 seconds
makes sense. But, if the order of those two waves was inverted, the first wave would load
Thumbs every 10 seconds already and then the 1-minute wave would be useless.-
Constructor Summary
ConstructorDescriptionBuilder()
Empty BuilderBuilder
(LoadingStrategy loadingStrategy) Create a Builder with the provided LoadingStrategy. -
Method Summary
Modifier and TypeMethodDescriptionaddPercentageWave
(float percentage) Adds a percentage Wave.addStepWave
(int step) Adds a Step Wave.addTimeWave
(int time, TimeUnit timeUnit) Adds a time Wave.get()
Builds theLoadingStrategy
with the WavesloadStartDelayMs
(long loadStartDelayMs) Time in milliseconds after which the Thumbnails will start to be loaded.
-
Constructor Details
-
Builder
public Builder()Empty Builder -
Builder
Create a Builder with the provided LoadingStrategy. If null, an the starting strategy will be empty.- Parameters:
loadingStrategy
- the strategy to initialise the Builder.
-
-
Method Details
-
addTimeWave
Adds a time Wave. Time waves define the amount of time between thumbnails.- Parameters:
time
- Time to be the gap between any two consecutive loaded thumbnailstimeUnit
- TimeUnit. Must be greater or equal to 0.- Returns:
- the builder
-
addPercentageWave
Adds a percentage Wave. Defines the time percentage of the media between thumbnails.- Parameters:
percentage
- percentage of the media to be the gap between any two consecutive loaded thumbnails. Must be between 0 and 1.- Returns:
- the builder
-
addStepWave
Adds a Step Wave. Defines the separation between the thumbnails, regardless of their duration.- Parameters:
step
- the separation between two consecutive loaded thumbnails. Must be 1 or greater.- Returns:
- the builder
-
loadStartDelayMs
Time in milliseconds after which the Thumbnails will start to be loaded. Set to 0 to start loading immediately upon playback start. Set C.TIME_UNSET to start loading only on-demand, wheneverThumbnailProvider.getThumbnail(long, ThumbnailProvider.Callback, int)
is called for the first time. Default is C.TIME_UNSET- Parameters:
loadStartDelayMs
- delay time until thumbnail load start.- Returns:
- the builder
-
get
Builds theLoadingStrategy
with the Waves- Returns:
LoadingStrategy
instance
-