Class LoadingStrategy

  • All Implemented Interfaces:
    Iterable<com.castlabs.sdk.thumbs.LoadingStrategy.Wave>

    public class LoadingStrategy
    extends Object
    implements Iterable<com.castlabs.sdk.thumbs.LoadingStrategy.Wave>
    Defines in what order to load (cache) thumbnails. The goal of defining a strategy is to spread out the loading of the thumbnails so that they are not sequentially loaded and to quickly have "significant" thumbnails for most of the content in a reasonable time.

    To achieve this, the LoadingStrategy defines waves. Each Wave defines the space between thumbnails to be loaded. A more spaced-out Wave will load fewer thumbnails and finish preloading faster, but will provide less accurate thumbnails. A less spaced Wave will provide more accurate thumbnails but taking longer to complete.

    Currently, there's three ways of adding Waves:

    • LoadingStrategy.TimeWave: defines the amount of time between thumbnails
    • LoadingStrategy.PercentageWave: defines the time percentage of the media between thumbnails
    • LoadingStrategy.StepWave: defines the number of thumbnails to skip between two thumbnails, regardless of their duration

    To construct a LoadingStrategy use the LoadingStrategy.Builder and add Waves to it with its addXWave(...) methods. Order *is important*. Waves will be loaded in sequential adding order. Make sure the most spread-out Wave is added first while the most granular is added last.

    Default Strategy is ThumbsPlugin.DEFAULT_LOADING_STRATEGY.

    Since:
    4.2.39
    • Method Detail

      • getLoadStartDelayMs

        public long getLoadStartDelayMs()
        The delay time until thumbnail load starts in milliseconds
        Returns:
        delay time until thumbnail load starts in milliseconds
      • iterator

        @NonNull
        public Iterator<com.castlabs.sdk.thumbs.LoadingStrategy.Wave> iterator()
        Specified by:
        iterator in interface Iterable<com.castlabs.sdk.thumbs.LoadingStrategy.Wave>