DASH-IF thumbnails example code
To test this feature and view the example code, please see the Android SDK 5 Example Code Quick Start guide.
The operation is instigated by the application providing the OTVVideoView
instance with a thumbnail listener before providing it with the stream’s URL. So that playback start time is not compromised, thumbnails are prepared asynchronously; this also means that the VOD thumbnails are not available at the very beginning of playback. The SDK notifies the application of the thumbnail preparation state through the provided listener and, once prepared, will provide the application with a thumbnail view to display.
Preparation time (the time it takes from the start of playback until thumbnails are available for preview) depends on the number of thumbnails and their size (bandwidth). This could take a fraction of a second for short content with few thumbnails to several seconds for long-duration content with a high density of thumbnails.
Preparing a listener in the application
private IOTVThumbnailListener mThumbnailListener = new IOTVThumbnailListener() {
@Override
public void noThumbnails() {
// Info: No thumbnails for the given stream
}
@Override
public void preparing() {
// Info: Got a DASH manifest with thumbnails. Preparing thumbnails
}
@Override
public void prepared(OTVThumbnailView xView) {
// Thumbnails are prepared and the thumbnail view is provided as a parameter
// Note: this callback is NOT called on the UI thread.
}
@Override
public void error(int reason) {
// Failed to fetch thumbnails for some reason
// The reason parameter represents one of the OTVThumbnailError integer constants
}
};
Just before setting the video path of the stream to play, provide the OTVVideoView
instance with the thumbnail listener
mOTVVideoView.setThumbnailListener(mThumbnailListener);
// ...
mOTVVideoView.setVideoPath(STREAM_URI);
The OTVThumbnailView
instance provided in the prepared()
callback is used to display all thumbnails. The application needs to update the view with the correct image by specifying the desired time. The SDK will match the position (in milliseconds) with the correct thumbnail image.
thumbnailView.seekTime(positionMs);
The example code implements a simple seek bar in a ThumbnailMediaController
class which demonstrates the usage of the thumbnail view provided in the prepared()
callback.