Package com.castlabs.sdk.thumbs

# Class VttThumbnailProvider

java.lang.Object
com.castlabs.sdk.thumbs.BaseThumbnailProvider
com.castlabs.sdk.thumbs.VttThumbnailProvider

All Implemented Interfaces:
  `ThumbnailProvider`

public class VttThumbnailProvider extends BaseThumbnailProvider
Provided thumbnails from WebVTT files.

The implementation assumes that each thumbnail is referenced as a Cue entry in the VTT file. Gridded thumbnails are supported using the `#xywh=<x>,<y>,<width>,<height>` anchor on the linked file. If images are linked relative, the URL is resolved based on the base URL of the VTT file.

Since:
  4.0.0

- ## Nested Class Summary

  ## Nested classes/interfaces inherited from interface com.castlabs.sdk.thumbs.ThumbnailProvider

  `ThumbnailProvider.Callback, ThumbnailProvider.IndexRefreshListener, ThumbnailProvider.RequestQueuePosition, ThumbnailProvider.ThumbnailResult`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `VttThumbnailProvider(com.castlabs.sdk.thumbs.ThumbnailLoader.Factory loaderFactory, PlayerController playerController, LoadingStrategy loadingStrategy, Uri sourceUri)`
  Creates a new VTT thumbnail provider.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `cancelPendingRequests()`
  Cancels any queued Thumbnail Requests.
  `boolean`
  `cancelRequests(long positionFromUs, long positionToUs)`
  Removes previously queued explicit requests (through the getThumbnail methods), whose requests positions' within the specified position range.
  `void`
  `destroy()`
  Free up all the resources, meaning this provider will not be used anymore
  `DownloadableResource[]`
  `getDownloadableResources(String remoteManifestUrl, File basePath, Bundle bundle)`
  This methods is used to integrate a thumbnail provider with the downloader plugins and implementation can return an array of resources that should be fetched for offline playback.
  `Future<ThumbnailProvider.ThumbnailResult>`
  `getThumbnail(long positionUs, int thumbnailIndex, long positionToleranceUs)`
  Load the thumbnail for the given position and return a `Future` linked to the operation.
  `void`
  `getThumbnail(long positionUs, ThumbnailProvider.Callback callback, int thumbnailIndex, long positionToleranceUs)`
  Load the thumbnail for the given position and return it through the provided callback.
  `void`
  `onThumbnailRequestFinished(com.castlabs.sdk.thumbs.ThumbnailRequest request, boolean completed)`
  `void`
  `refreshThumbnails(long positionUs)`
  Trigger an refresh of the internal thumbnail index
  `void`
  `setLoadingStrategy(LoadingStrategy loadingStrategy)`
  Updates the `LoadingStrategy` of this provider.
  `void`
  `setRequestQueuePosition(ThumbnailProvider.RequestQueuePosition queuePosition)`
  Set where in the loading queue shall new thumbnail requests be placed.

  ### Methods inherited from class com.castlabs.sdk.thumbs.BaseThumbnailProvider

  `addIndexRefreshListener, getCuePointsList, getThumbnailPosition, removeIndexRefreshListener`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

  ### Methods inherited from interface com.castlabs.sdk.thumbs.ThumbnailProvider

  `getThumbnail, getThumbnail`

- ## Constructor Details

  - ### VttThumbnailProvider

    public VttThumbnailProvider(@NonNull com.castlabs.sdk.thumbs.ThumbnailLoader.Factory loaderFactory, @Nullable PlayerController playerController, @Nullable LoadingStrategy loadingStrategy, @NonNull Uri sourceUri)
    Creates a new VTT thumbnail provider.
    Parameters:
      `loaderFactory` - The factory to create thumbnail loaders
      `playerController` - The player controller instance, can be null
      `loadingStrategy` - The loading strategy to use, can be null
      `sourceUri` - The URI of the WebVTT file

- ## Method Details

  - ### onThumbnailRequestFinished

    public void onThumbnailRequestFinished(com.castlabs.sdk.thumbs.ThumbnailRequest request, boolean completed)

  - ### cancelPendingRequests

    public void cancelPendingRequests()
    Description copied from interface: `ThumbnailProvider`
    Cancels any queued Thumbnail Requests. Requests currently processing won't be cancelled.
    Specified by:
      `cancelPendingRequests` in interface `ThumbnailProvider`

  - ### setLoadingStrategy

    public void setLoadingStrategy(@NonNull LoadingStrategy loadingStrategy)
    Description copied from interface: `ThumbnailProvider`
    Updates the `LoadingStrategy` of this provider. If thumbnails are already loading, this might not have an immediate effect.
    Specified by:
      `setLoadingStrategy` in interface `ThumbnailProvider`
    Parameters:
      `loadingStrategy` - the loading strategy to set

  - ### setRequestQueuePosition

    public void setRequestQueuePosition(@NonNull ThumbnailProvider.RequestQueuePosition queuePosition)
    Description copied from interface: `ThumbnailProvider`
    Set where in the loading queue shall new thumbnail requests be placed. Either front or back.
    Specified by:
      `setRequestQueuePosition` in interface `ThumbnailProvider`
    Parameters:
      `queuePosition` - the position where to insert the upcoming thumbnail requests

  - ### destroy

    public void destroy()
    Description copied from interface: `ThumbnailProvider`
    Free up all the resources, meaning this provider will not be used anymore
    Specified by:
      `destroy` in interface `ThumbnailProvider`
    Overrides:
      `destroy` in class `BaseThumbnailProvider`

  - ### getDownloadableResources

    @Nullable public DownloadableResource[] getDownloadableResources(String remoteManifestUrl, File basePath, Bundle bundle)
    Description copied from interface: `ThumbnailProvider`
    This methods is used to integrate a thumbnail provider with the downloader plugins and implementation can return an array of resources that should be fetched for offline playback.
    Specified by:
      `getDownloadableResources` in interface `ThumbnailProvider`
    Parameters:
      `remoteManifestUrl` - The manifest URL of the remote manifest that is the source of this download
      `basePath` - The base folder for this download
      `bundle` - The bundle that was used to start the initiate the download
    Returns:
      Array of downloadable resources or null

  - ### getThumbnail

    public void getThumbnail(long positionUs, ThumbnailProvider.Callback callback, @ThumbnailIndex int thumbnailIndex, long positionToleranceUs)
    Description copied from interface: `ThumbnailProvider`
    Load the thumbnail for the given position and return it through the provided callback.
    Specified by:
      `getThumbnail` in interface `ThumbnailProvider`
    Parameters:
      `positionUs` - The position in microseconds
      `callback` - The callback that will be triggered once data are available
      `thumbnailIndex` - Position of the Thumbnail relative to its timestamp
      `positionToleranceUs` - Maximum tolerance time between the time of the requested thumbnail and a potentially already-loaded thumbnail in the index. If a matching nearby thumbnail with data is found, it will be returned immediately. Otherwise the requested thumbnail will be scheduled for fetching. If 0, the exact thumbnail will always be returned, loading it if necessary.

  - ### cancelRequests

    public boolean cancelRequests(long positionFromUs, long positionToUs)
    Description copied from interface: `ThumbnailProvider`
    Removes previously queued explicit requests (through the getThumbnail methods), whose requests positions' within the specified position range. If the request was issued with a `ThumbnailProvider.Callback` it will be invoked.

    Specified by:
      `cancelRequests` in interface `ThumbnailProvider`
    Parameters:
      `positionFromUs` - minimum position for cancelling a request (inclusive)
      `positionToUs` - maximum position for cancelling a request (exclusive)
    Returns:
      whether at least one request has been cancelled by the method call

  - ### getThumbnail

    public Future<ThumbnailProvider.ThumbnailResult> getThumbnail(long positionUs, int thumbnailIndex, long positionToleranceUs)
    Description copied from interface: `ThumbnailProvider`
    Load the thumbnail for the given position and return a `Future` linked to the operation.
    Specified by:
      `getThumbnail` in interface `ThumbnailProvider`
    Parameters:
      `positionUs` - The position in microseconds
      `thumbnailIndex` - Position of the Thumbnail relative to its timestamp
      `positionToleranceUs` - Maximum tolerance time between the time of the requested thumbnail and a potentially already-loaded thumbnail in the index. If a matching nearby thumbnail with data is found, it will be returned immediately. Otherwise the requested thumbnail will be scheduled for fetching. If 0, the exact thumbnail will always be returned, loading it if necessary.
    Returns:
      a Future identifying the request

  - ### refreshThumbnails

    public void refreshThumbnails(long positionUs)
    Trigger an refresh of the internal thumbnail index
    Parameters:
      `positionUs` - the playback position to consider as root point when calculating the load order, if needed