Skip to main content

Using the Player API

Viostream's Player API allows you to dynamically embed videos onto a web page using Javascript. This is an advanced featured intended for developers who want to build an interactive experience around the Viostream Player.

Include the Javascript

Include the Viostream script on each page of your website where you want to load video — it should always be loaded directly from https://play.viostream.com, rather than included in a bundle or hosted yourself. Replace ACCOUNT_KEY with your account key in the link below.

<script src="https://play.viostream.com/api/ACCOUNT_KEY"></script>
note

If you don't provide the correct account key, many features may not work, or may behave unpredictably.

API Documentation

Ready

Use $viostream.ready(handler) to delay execution of a function until after the DOM is ready for Viostream to modify.

ParameterTypeDescription
handlerfunctionA function to execute once the DOM is ready for Viostream to modify
Example
<script>
$viostream.ready(function () {
console.info("DOM is ready");
});
</script>

Embed

Use $viostream.embed(publicKey, target, options?) to embed a video inside the target element in the DOM.

ParameterTypeDescription
publicKeystringThe public key of the Media Asset you wish to embed.
targetstringThe id of the container (e.g. <div>) into which you wish to place the Player.
optionsobjectPlayer settings object. This can be used to specify the Player key, and to override any of the supported player settings.
options.audioOnlyPlayerboolRender a slim audio-only player.
options.chaptersboolOverride the player's chapter display default.
options.chapterDisplayTypestringOverride the player's chapter display type. dropdown, progressbar or horizontal.
options.chapterSlugstringSeek to a chapter point before playing.
options.displayTitleboolOverride the player's display title default.
options.hlsQualitySelectorboolOverride the player's HLS quality selector default.
options.playerKeystringSpecify a player to use.
options.sharingboolOverride the player's sharing default.
options.speedSelectorboolOverride the player's speed selector default.
options.startEndTimespanstringPlay a specific section of a video.
options.startTimestringSeek to a point in the video before playing.
options.transcriptDownloadboolOverride the player's transcript download default.
Example
<div id="my-video-div" />
<script>
$viostream.ready(function () {
$viostream.embed("nhedxonrxsyfee", "my-video-div", {
chapterSlug: "chapter-1",
displayTitle: true,
hlsQualitySelector: true,
sharing: true,
speedSelector: true,
transcriptDownload: true,
});
});
</script>