Package com.castlabs.sdk.thumbs

## Interface DefaultThumbnailView.Callback

- Enclosing class:
    DefaultThumbnailView

      public static interface DefaultThumbnailView.Callback

  Users of this render must provide an implementation of this callback when they call `DefaultThumbnailView.show(long, Callback)`. The callbacks `getThumbnailRect(Rect, ThumbnailInfo, boolean)` method is then used to determine the desired size and location of the thumbnail.

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `getThumbnailRect​(Rect output, DefaultThumbnailView.ThumbnailInfo info, boolean isSmallScreen)` | Called on the main thread as part of the `DefaultThumbnailView.onDraw(Canvas)` implementation.

- - ### Method Detail

    - #### getThumbnailRect

          void getThumbnailRect​(Rect output,
                                DefaultThumbnailView.ThumbnailInfo info,
                                boolean isSmallScreen)

      Called on the main thread as part of the `DefaultThumbnailView.onDraw(Canvas)` implementation. Do not perform any heavy duty tasks in the implementation of this method.

      The purpose of this call is that the implementer fills the values of the provided `output` rectangle. The thumbnail will that be rendered inside that rectangle. Note tha the image will be rendered starting in the top left corner and the renderer will try to respect the desired size, but it will always maintain the original aspect ratio. An example implementation of this interface can look like:

           public void getThumbnailRect(Rect output, DefaultThumbnailView.ThumbnailInfo info, boolean isSmallScreen) {
                  if(!isSmallScreen) {
                          // If we are not in a small screen, we take the
                          // video container and render on top of it. This assumes that
                          // the thumbnail has the same aspect ratio as the video, so that
                          // the whole view will be covered
                          ViewGroup videoView = playerView.getVideoView();
                          output.set(
                                          videoView.getLeft(),
                                          videoView.getTop(),
                                          videoView.getRight(),
                                          videoView.getBottom());
                  } else {
                          // If this is not a small screen device, we scale up the original thumbnail
                          // 2x and draw it on top of our bottom container that holds the seekbar
                          // and leave some space to the left and right
                          int tw = thumbWidth * 2;
                          int th = thumbHeight * 2;
                          int left = (int) (10 + (bottomContainer.getWidth() - tw - 20) * lastSeekBarProgressPercent);
                          int top = bottomContainer.getTop() - th - 30;
                          output.set(left, top, left + tw, top + th);
                  }
           }

      The example above assumes that the `DefaultThumbnailView` view sits on top of the `PlayerView` and has the same dimensions. We then fill the output rectangle using the coordinates of the `PlayerView.getVideoView()`, which is the container that holds the video surface and has the same dimensions as the currently played video frame. This means that the thumbnail will be scaled up and will overlay the video view entirely. In contrast to the full screen behaviour on the small screen, we use a smaller but still scaled version of the thumbnail in case we are on a bigger screen. In that case the thumbnail is positioned above our bottom container that holds the seek bar and we let it follow the seek-bar movement.
      Parameters:
        `output` - The output rectangle that needs to be filled in the implementation of this method
        `info` - Thumbnail information. For performance reasons, the instance of this object will be modified and re-used in subsequent calls of this method.
        `isSmallScreen` - True if the current screen was detected as a small screen.