Previewing videos

A preview video is a great way to encourage users to deep-link into your TV app.
Previews can range from short clips to full movie trailers.

When you create a preview, consider these guidelines:

Do not show ads in a preview. If you stitch ads on the client side,
do not stitch them into preview videos. If you stich ads on the server side,
provide an ad-free video for previews.

For best quality, preview videos should be 16:9 or 4:3. See
Video program attributes
for the recommended sizes of preview videos.

When the preview video and the poster art have different aspect ratios the
home screen resizes the poster view to the video's aspect ratio before playing the preview.
The video is not letterboxed. For example, if
the poster art ratio is
ASPECT_RATIO_MOVIE_POSTER (1:1.441)
but the video ratio is 16:9, the poster view transforms to a 16:9 region.

When you create a preview its content can be publicly accessible or
protected under DRM. Different procedures apply in each case. This page
describes both.

Play the preview on the home screen

If you create a preview using any of the video types
supported by ExoPlayer
and the preview is publicly accessible, you can play the preview directly on the home screen.

When you build a PreviewProgram
use setPreviewVideoUri() with a publicly accessible HTTPS
URL as shown in the example below. The preview can be either
video or
audio.

Direct surface rendering lets your app control what is rendered and how it is
rendered. You can overlay metadata such as channel attribution.

Declare your TvInputService in the manifest

Your app must provide an implementation of TvInputService
so the home screen can render your preview.

In your service declaration, include an intent filter that specifies
TvInputService as the action to perform with the
intent. Also declare the service metadata as a separate XML resource. The
service declaration, intent filter, and service metadata declaration are shown
in the following example:

Define the service metadata in a separate XML file.
The service metadata file is located in the XML resources directory
for your app and must match the name of the resource you declared in the
manifest. Using the manifest entries from the previous example, you would
create an XML file at res/xml/previewinputservice.xml, with an empty
tv-input tag:

<?xml version="1.0" encoding="utf-8"?>
<tv-input/>

TV Input Framework must have this tag. However,
it's only used to configure live channels. Since you are rendering a video,
the tag should be empty.

Create a video URI

To indicate that your preview video should be rendered by your app rather than
the Android TV home screen, you must create a video URI for a PreviewProgram.
The URI should end with the identifier that your app uses for the content, so you
can retrieve the content later in the TvInputService.

Create a service

The following example shows how to extend TvInputService to create your own
PreviewInputService. Note that the service uses a MediaPlayer for playback,
but your code can use any available video player.