メインコンテンツまでスキップ

Thumbnail Seeking

Thumbnail seeking enables users to quickly navigate through longer videos by displaying preview images associated with specific timestamps when hovering over the progress bar or seeking through the video.

Enabling Thumbnail Seeking

To enable thumbnail seeking, provide a VTT (WebVTT) file containing thumbnail image URLs and assign it to the sourceConfig:

if let thumbnailString = "https://example.com/web.vtt",
let thumbnailUrl = URL(string: thumbnailString) {

sourceConfig.thumbnailTrack = UniThumbnailTrack(
url: thumbnailUrl, // URL of the WebVTT file containing thumbnail metadata.
label: "Thumbnail Track", // Descriptive label for the track.
identifier: "unique-id", // Unique identifier for reference.
isDefaultTrack: false // Set to true if this should be the default track.
)
}

Retrieving and Displaying Thumbnails

Once the thumbnail track is configured, you can retrieve a thumbnail image for a specific timestamp and display it in the UI:

if let thumbnail = player.source?.thumbnail(forTime: time) {
.....
}
}