VideoThumbnail
widget in Supervisely is a widget that allows to display a thumbnail image that represents specific video. It is a useful widget for applications that work with videos, allowing users to have quick access to this video, so that when the user clicks on the thumbnail, the link will take him to this video.
VideoThumbnail(info=None, widget_id=None)
Parameters | Type | Description |
---|---|---|
info |
VideoInfo |
NamedTuple , containing information about video project |
widget_id |
str |
ID of the widget |
NamedTuple
, containing information about video project.
type: VideoInfo
default value: None
video_info = api.video.get_info_by_id(video_id)
video_thumbnail = VideoThumbnail(info=video_info)
ID of the widget.
type: str
default value: None
Attributes and Methods | Description |
---|---|
set_video(info: VideoInfo) |
Set input video project data by video project info. |
set_video_id(id: int) |
Set input video project data by video project id. |
You can find this example in our Github repository:
ui-widgets-demos/thumbnail/003_video_thumbnail/src/main.py
import os
import supervisely as sly
from dotenv import load_dotenv
from supervisely.app.widgets import Card, Container, VideoThumbnail
First, we load environment variables with credentials and init API for communicating with Supervisely Instance:
load_dotenv("local.env")
load_dotenv(os.path.expanduser("~/supervisely.env"))
api = sly.Api()
video_id = int(os.environ["modal.state.slyVideoId"])
video_info = api.video.get_info_by_id(id=video_id)
video_thumbnail = VideoThumbnail(info=video_info)
Prepare a layout for app using Card
widget with the content
parameter and place widget that we've just created in the Container
widget.
card = Card(
title="Video Thumbnail",
content=Container(widgets=[video_thumbnail]),
)
layout = Container(widgets=[card])
Create an app object with layout parameter.
app = sly.Application(layout=layout)