Vivid API

Video Player

Video Player is a component used to play and control video content.

Usage

import { registerVideoPlayer } from '@vonage/vivid-api';
registerVideoPlayer('your-prefix');

Src

The src attribute provides a video source to the component.

Supported Video Formats

Video player supports the most common video formats:

Video formatDescription
HLSHTTP Live Streaming: (used in the example above) one of the most widely used video streaming protocols.
DASHDynamic Adaptive Streaming over HTTP
MP4one of the most widely supported video formats and is typically used for web video playback.
WebMopen media file format designed for the web and widely supported by modern browsers.
Ogga container format that can contain video streams compressed with Theora video codec and audio streams compressed with Vorbis audio codec.

Source element

A video source can alternatively be provided to the component using the source element.

<source src="../elephantsdream/ed_hd.mp4" type="video/mp4" />

The most common and widely supported format is mp4 (as in the exmaple below). Multiple formats can be provided for greater browser compatibility by defining multiple source elements

<vwc-video-player>
<source src="../elephantsdream/ed_hd.mp4" type="video/mp4" />
<source src="../elephantsdream/ed_hd.webm" type="video/webm" />
</vwc-video-player>

Text tracks

Text tracks are a feature of HTML5 for displaying time-triggered text to the end-user. They can come in the form of Captions, Subtitles, Audio descriptions and Chapters.

Timed text requires a text file in WebVTT format. This format defines a list of “cues” that have a start time, an end time, and text to display.

Text tracks can be provided using the track element.

<track src="../elephantsdream/captions.en.vtt" kind="captions" srclang="en" label="English" default />

Track element API

AttributeDescription
srcurl string (relative or absolute) that points to the captions file
kinddenotes the type of track file, in this case captions, but it could be subtitles, description or chapters (see below)
srclangindicates what language each subtitle files’ contents are in
labelto be shown in the menu when selecting the captions
defaultwhen set, the captions will be active when the video plays

Types of text track

Track typeDescription
CaptionsFor accessibility, it is recommended to provide captions to accompany any spoken word video. This is to help deaf and hard-of-hearing audiences and users who want to play the video on mute.
SubtitlesProvide translation of content that cannot be understood by the viewer. For example speech or text that is not English in an English language film.
Audio descriptionTo cater for blind and partially sighted users, a description track can be provided for screen readers. They are a textual description of the video content.
ChaptersChapters are intended to be used when the user is navigating the media resource.

Auto play / loop

Both autoplay and loop attributes are boolean. When autoplay is set, the video will play automatically as soon as it loads, the sound will be muted.

When loop is set, the video will restart automatically when it reaches the end.

API Reference

Properties

PropertyTypeDefaultDescription
autoplaybooleanSets the video to start playing automatically after loading
loopbooleanSets the video to loop
playbackRatesstringSets the possible playback rates
posterstringReference to poster image's source
skipBy'0' | '5' | '10' | '30'Sets the amount to skip
srcstringReference to the video's source
PropertyTypeDefaultDescription
autoplaybooleanSets the video to start playing automatically after loading
loopbooleanSets the video to loop
playback-ratesstringSets the possible playback rates
posterstringReference to poster image's source
skip-by'0' | '5' | '10' | '30'Sets the amount to skip
srcstringReference to the video's source

Slots

NameDescription
defaultDefault slot
NameDescription
defaultDefault slot

Events

NameTypeDescription
endedCustomEvent<undefined>Fired when the video is ended
pauseCustomEvent<undefined>Fired when the video is paused
playCustomEvent<undefined>Fired when the video is played
NameTypeDescription
endedCustomEvent<undefined>Fired when the video is ended
pauseCustomEvent<undefined>Fired when the video is paused
playCustomEvent<undefined>Fired when the video is played