Package com.castlabs.sdk.thumbs
Class LoadingStrategy.Builder
- java.lang.Object
-
- com.castlabs.sdk.thumbs.LoadingStrategy.Builder
-
- Enclosing class:
- LoadingStrategy
public static final class LoadingStrategy.Builder extends Object
Builder forLoadingStrategy
. 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 aTimeWave
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
Constructors Constructor Description Builder()
Empty BuilderBuilder(LoadingStrategy loadingStrategy)
Create a Builder with the provided LoadingStrategy
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description LoadingStrategy.Builder
addPercentageWave(float percentage)
Adds a percentage Wave.LoadingStrategy.Builder
addStepWave(int step)
Adds a Step Wave.LoadingStrategy.Builder
addTimeWave(int time, TimeUnit timeUnit)
Adds a time Wave.LoadingStrategy
get()
Builds theLoadingStrategy
with the WavesLoadingStrategy.Builder
loadStartDelayMs(long loadStartDelayMs)
Time in milliseconds after which the Thumbnails will start to be loaded.
-
-
-
Constructor Detail
-
Builder
public Builder()
Empty Builder
-
Builder
public Builder(@NonNull LoadingStrategy loadingStrategy)
Create a Builder with the provided LoadingStrategy- Parameters:
loadingStrategy
- the strategy to initialise the Builder.
-
-
Method Detail
-
addTimeWave
public LoadingStrategy.Builder addTimeWave(int time, @NonNull TimeUnit timeUnit)
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
public LoadingStrategy.Builder addPercentageWave(float percentage)
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
public LoadingStrategy.Builder addStepWave(int step)
Adds a Step Wave. Defines the number of thumbnails to skip between two thumbnails, regardless of their duration.- Parameters:
step
- number of thumbnails apart between two consecutive loaded thumbnails. Must be 1 or greater.- Returns:
- the builder
-
loadStartDelayMs
public LoadingStrategy.Builder loadStartDelayMs(long 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
public LoadingStrategy get()
Builds theLoadingStrategy
with the Waves- Returns:
LoadingStrategy
instance
-
-