Class ThumbsPlugin
The plugin module exposes two main interfaces, ThumbnailLoader
to load raw images
from a data source and ThumbnailProvider
that handles the asynchronous delivery to
a view.
The plugin expose a default ThumbnailProvider
through
PlayerController.getComponent(Class)
if playback is started with an intent bundle,
i.e. PlayerController.open(Bundle)
is used to start playback. The provider assumes
that you add an instance of ThumbnailDataTrack
with the key INTENT_THUMBNAILS_DATA
to the bundle. If that is the case the provider will be fully initialized and can be accessed
through:
ThumbnailProvider provider = playerController.getComponent(ThumbnailProvider.class);
The provider can then be used in a View
to render thumbnail images. The plugin also
provides DefaultThumbnailView
as a default implementation. You can use that view
to add it manually to you view hierarchy, but you can also register the plugin with the
default view component enabled. In that case in instance of DefaultThumbnailView
will
automatically added to the PlayerView
and will be initialized
with the provider component. In that case you can access the component through
PlayerView.getComponent(Class)
, for example:
ThumbnailViewComponent thumbsView = playerView.getComponent(ThumbnailViewComponent.class);
The view component exposes ThumbsPlugin.ThumbnailViewComponent.show(long, DefaultThumbnailView.Callback)
and ThumbsPlugin.ThumbnailViewComponent.hide()
to control thumbnail rendering.
- Since:
- 4.0.0
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
If you registered the plugin with the default view integration enabled, this component will be registered with thePlayerView
and you can access it to trigger displaying thumbnails. -
Field Summary
Modifier and TypeFieldDescriptionstatic final LoadingStrategy
Default loading strategy for thumbnails.static final String
Deprecated.static final int
Id for the defaultDefaultThumbnailView
static final LoadingStrategy
Sequential loading strategy.static final int
When used inDefaultThumbnailView.show(long, DefaultThumbnailView.Callback, int)
will render the closest thumbnail.static final int
When used inDefaultThumbnailView.show(long, DefaultThumbnailView.Callback, int)
will render the current thumbnail.static final int
When used inDefaultThumbnailView.show(long, DefaultThumbnailView.Callback, int)
will render the next thumbnail. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic ThumbnailProvider
createProvider
(PlayerController playerController, ThumbnailDataTrack thumbnailData, LoadingStrategy loadingStrategy, String manifestUrl) Same ascreateProvider(PlayerController, ThumbnailDataTrack, LoadingStrategy, String, ThumbnailLoader.Factory)
but with a default loader implementation.static ThumbnailProvider
createProvider
(PlayerController playerController, ThumbnailDataTrack thumbnailData, LoadingStrategy loadingStrategy, String manifestUrl, com.castlabs.sdk.thumbs.ThumbnailLoader.Factory loaderFactory) Create a thumbnail provider based on thetype
.getId()
static int
Returns the number of Threads that will be used to load image-based Thumbnails.void
setLoadingStrategy
(LoadingStrategy loadingStrategy) Sets theLoadingStrategy
to use for loading thumbnails.static void
setThumbnailLoadThreads
(int loadThreadCount) Set the number of Threads that will be used to load image-based Thumbnails.Methods inherited from class com.castlabs.android.Plugin
init, onRemotePlay
-
Field Details
-
INTENT_THUMBNAILS_DATA
Deprecated.in favour ofSdkConsts.INTENT_SIDELOADED_TRACKS_ARRAYLIST
andSideloadedTrack.ThumbnailBuilder
.Use this key to storeThumbnailDataTrack
in an intent.- See Also:
-
DEFAULT_LOADING_STRATEGY
Default loading strategy for thumbnails. Load will be triggered upon the first Thumbnail request. Defines 3 waves:- 1 Minute: A thumbnail will be loaded for every minute of the content
- 15 Seconds: A thumbnail will be loaded for every 15 seconds of the content
- All thumbnails will be loaded
-
SEQUENTIAL_LOADING_STRATEGY
Sequential loading strategy. Naive strategy which simply loads all thumbnails sequentially. Thumbnails will start to load immediately. Corresponds to the legacy behaviour beforeLoadingStrategy
was introduced. -
PRESTO_DEFAULT_THUMBNAIL_VIEW
@IdRes public static final int PRESTO_DEFAULT_THUMBNAIL_VIEWId for the defaultDefaultThumbnailView
-
THUMBNAIL_INDEX_CURRENT
public static final int THUMBNAIL_INDEX_CURRENTWhen used inDefaultThumbnailView.show(long, DefaultThumbnailView.Callback, int)
will render the current thumbnail. This corresponds to the thumbnail with the highest media time that is lower than the requested position.- See Also:
-
THUMBNAIL_INDEX_NEXT
public static final int THUMBNAIL_INDEX_NEXTWhen used inDefaultThumbnailView.show(long, DefaultThumbnailView.Callback, int)
will render the next thumbnail. This corresponds to the thumbnail with the lowest media time that is higher than the requested position.- See Also:
-
THUMBNAIL_INDEX_CLOSEST
public static final int THUMBNAIL_INDEX_CLOSESTWhen used inDefaultThumbnailView.show(long, DefaultThumbnailView.Callback, int)
will render the closest thumbnail. This corresponds to the thumbnail with the lowest difference between its media time and the requested position.- See Also:
-
-
Constructor Details
-
ThumbsPlugin
public ThumbsPlugin(boolean useDefaultView) Create a new instance of this plugin. You can specify if the default renderer view should be registered. If you want to use the default renderer view, seeThumbsPlugin.ThumbnailViewComponent
for more information how to access and use the view.- Parameters:
useDefaultView
- Register the default renderer view
-
-
Method Details
-
setLoadingStrategy
Sets theLoadingStrategy
to use for loading thumbnails. Applies for VTT, JPG and DASH embedded thumbnails.Can be later set at runtime, between playback sessions through
ThumbnailProvider.setLoadingStrategy(LoadingStrategy)
.- Parameters:
loadingStrategy
- the strategy to use. Must be non null and contain at least one Wave.- See Also:
-
getId
-
createProvider
@Nullable public static ThumbnailProvider createProvider(@NonNull PlayerController playerController, @NonNull ThumbnailDataTrack thumbnailData, @NonNull LoadingStrategy loadingStrategy, @Nullable String manifestUrl) Same ascreateProvider(PlayerController, ThumbnailDataTrack, LoadingStrategy, String, ThumbnailLoader.Factory)
but with a default loader implementation.- Parameters:
playerController
- The player controller instancethumbnailData
- The thumbnail dataloadingStrategy
- The thumbnail loading strategymanifestUrl
- URL to the manifest that is used to infer the absolute URL to the thumbnails in caseurl
is relative- Returns:
- The provider
- Throws:
IllegalArgumentException
- in case the type of the thumbnail format is not specified and could not be inferred.
-
createProvider
@Nullable public static ThumbnailProvider createProvider(@NonNull PlayerController playerController, @NonNull ThumbnailDataTrack thumbnailData, @NonNull LoadingStrategy loadingStrategy, @Nullable String manifestUrl, @Nullable com.castlabs.sdk.thumbs.ThumbnailLoader.Factory loaderFactory) Create a thumbnail provider based on thetype
. If the type is unknown, it will be inferred from the extension (i.e. .bif, .vtt, or .jpg of the URL. If the type could not be inferred, an exception is raised.- Parameters:
playerController
- The player controller instancethumbnailData
- The thumbnail dataloadingStrategy
- The thumbnail loading strategymanifestUrl
- URL to the manifest that is used to infer the absolute URL to the thumbnails in caseurl
is relativeloaderFactory
- The thumbnail loader factory. Ifnull
the default factory will be generated- Returns:
- The provider
- Throws:
IllegalArgumentException
- in case the type of the thumbnail format is not specified and could not be inferred.
-
getThumbnailLoadThreads
public static int getThumbnailLoadThreads()Returns the number of Threads that will be used to load image-based Thumbnails.- Returns:
- the number of Threads that will be used for Thumbnail loading
-
setThumbnailLoadThreads
public static void setThumbnailLoadThreads(int loadThreadCount) Set the number of Threads that will be used to load image-based Thumbnails.- Parameters:
loadThreadCount
- number of Threads
-
SdkConsts.INTENT_SIDELOADED_TRACKS_ARRAYLIST
andSideloadedTrack.ThumbnailBuilder
.