Class LoadingStrategy.Builder

  • Enclosing class:
    LoadingStrategy

    public static final class LoadingStrategy.Builder
    extends Object
    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 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 thumbnails
        timeUnit - 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, whenever ThumbnailProvider.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