Video#
Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).
import panel as pn
pn.extension()
The Video pane displays a video player given a local or remote video file or raw video bytes. The pane also allows access and control over the player state including toggling of playing/paused and loop state, the current time, and the volume. Depending on the browser the video player supports mp4, webm, and ogg containers and a variety of codecs.
Parameters:#
For details on other options for customizing the component see the layout and styling how-to guides.
autoplay(boolean, default=False): When True, it specifies that the output will play automatically. In Chromium browsers this requires the user to click play once.loop(boolean, default=False): Whether to loop when reaching the end of playback.muted(boolean, default=False): When True, it specifies that the output should be muted.object(str, pathlib.Path, bytes or BytesIO): Local file path, remote URL pointing to a video file, or raw video bytes.paused(boolean, default=True): Whether the player is paused.throttle(int, default=250): How frequently to sample the current playback time in milliseconds.time(float): Current playback time in seconds.volume(int, default=100): Volume in the range 0-100.
The Video pane can be constructed with a URL pointing to a remote video file or a local video file (in which case the data is embedded):
video = pn.pane.Video('https://assets.holoviz.org/panel/samples/video_sample.mp4', width=640, loop=True)
video
The player can be controlled using its own widgets, as well as from Python. To start or stop playback in code, set the paused parameter (not executed here, so the page does not start playing on load):
video.paused = False
The current player time can be read and set with the time parameter (in seconds):
video.time
The volume may also be read and set:
video.volume = 50
Controls#
The Video pane exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:
pn.Row(video.controls(jslink=True), video)
Open this notebook in Jupyterlite | Download this notebook from GitHub (right-click to download).