跳到主要内容

Thumbnail Seeking

Thumbnail seeking allows users to quickly navigate through longer videos by displaying preview images associated with specific timestamps as they drag the progress bar.

To enable thumbnail seeking, add a VTT file with thumbnail image URLs to the MediaConfig:

// Step1. set this feature enabled
player.setPlayerOptions(
PlayerOption(
isThumbnailSeekingEnabled = true
)
)

// Step2. set the vtt with MediaConfig, and load it into player
val mediaConfig = MediaConfig(
...
thumbnailSeekingUrl = "$THUMBNAIL_URL",
)
player.load(mediaConfig)

If you want to customize your own thumbnail seeking view instead of official player UI. You can get the thumbnail by below suspend method.

// Step1. set this feature enabled
player.setPlayerOptions(
PlayerOption(
isThumbnailSeekingEnabled = true
)
)

// Step2. Get the picture of the drag progress bar position
val bitmap = player.getThumbnail(positionMs)

// Step3. Present it to the customize ImageView
Glide.with(context)
.load(bitmap)
.into(ImageView)