5.20.8-rc2 • Published 4 years ago

@uizaio/playerjs v5.20.8-rc2

Weekly downloads
10
License
MIT
Repository
github
Last release
4 years ago

Uiza Player Web SDK

License NPM version Build Status dependencies Status devDependencies Status npm.io

NPM

Uiza Player is a simple, lightweight, accessible and customizable HTML5, media player that supports modern browsers.

Demos

You can try Uiza in Codepen using our minimal templates. For Streaming we also have example integrations with: Hls.js, Dash.js and VOD

Quick setup

HTML

Uiza Player extends upon the standard HTML5 media element markup so that's all you need for those types.

AttributeValueDescription
autoplayautoplaySpecifies that the video will start playing as soon as it is ready
controlscontrolsSpecifies that video controls should be displayed (such as a play/pause button etc).
srcURLSpecifies the URL of the video file
heightpixelsSets the height of the video player
widthpixelsSets the width of the video player
looploopSpecifies that the video will start over again, every time it is finished
mutedmutedSpecifies that the audio output of the video should be muted
posterURLSpecifies an image to be shown while the video is downloading, or until the user hits the play button
preloadauto / metadata / noneSpecifies if and how the author thinks the video should be loaded when the page loads

HLS Stream Video

<video id='playerUz' crossorigin playsinline autoplay></video>
<script>
  var videoStreamURL = 'https://1955897154.rsc.cdn77.org/live/116881ad-3463-4209-b16f-50e0e48add10/master.m3u8?cm=eyJlbnRpdHlfaWQiOiI2ZWUyMzk5NS1mNGFhLTQ1ZDMtOTM5NS0xN2NlNjBlZWJjNDAiLCJlbnRpdHlfc291cmNlIjoibGl2ZSIsImFwcF9pZCI6IjkyYThkMjAzMmZlODQ5MmFhNzc4MDRiNGMyYzUxOWM1In0=';

(async (options) => {
  var uiza = await new Uiza(document.getElementById('playerUz'), options);
  return { uiza, time: Date.now() };
})({src: videoStreamURL});
</script>

See initialising for more information on advanced setups.

You can use our CDN for the JavaScript. There's 2 versions; one with and one without polyfills. My recommendation would be to manage polyfills seperately as part of your application but to make life easier you can use the polyfilled build.

<script src="https://sdk.uiza.io/v5/release/uiza.min.js"></script>

...or...

<script src="https://sdk.uiza.io/v5/release/uiza.polyfilled.js"></script>

CSS

Include the uiza.css stylsheet into your <head>.

<link rel="stylesheet" href="https://sdk.uiza.io/v5/release/uiza.css" />

Example

example.html

<!DOCTYPE html>
<html lang='en' dir='ltr'>

<head>
  <meta charset='utf-8'>
  <title></title>
  <meta name='viewport' content='width=device-width,initial-scale=1'>

  <link href='https://sdk.uiza.io/v5/release/uiza.css' rel='stylesheet'>
  <script src='https://sdk.uiza.io/v5/release/uiza.min.js'></script>

</head>

<body>
  <video id='playerUz' crossorigin playsinline autoplay></video>

  <script>
    var videoStreamURL = 'https://1955897154.rsc.cdn77.org/live/116881ad-3463-4209-b16f-50e0e48add10/master.m3u8?cm=eyJlbnRpdHlfaWQiOiI2ZWUyMzk5NS1mNGFhLTQ1ZDMtOTM5NS0xN2NlNjBlZWJjNDAiLCJlbnRpdHlfc291cmNlIjoibGl2ZSIsImFwcF9pZCI6IjkyYThkMjAzMmZlODQ5MmFhNzc4MDRiNGMyYzUxOWM1In0=';

    ((options) => {
      window.UZplayer = new Uiza(document.getElementById('playerUz'), options);
    })({ src: videoStreamURL });
  </script>

</body>

</html>

Advanced

Customizing HLS buffer

buffer: {
  maxBufferLength: 15
  maxMaxBufferLength: 90
}

maxBufferLength (default: 10 seconds, maximum 30 seconds)

Maximum buffer length in seconds. If buffer length is/become less than this value, a new fragment will be loaded. This is the guaranteed buffer length hls.js will try to reach, regardless of maxBufferSize.

maxMaxBufferLength: (default 60 seconds, maximum 120 seconds) Maximum buffer length in seconds. Hls.js will never exceed this value, even if maxBufferSize is not reached yet.

hls.js tries to buffer up to a maximum number of bytes (6 MB by default) rather than to buffer up to a maximum nb of seconds. this is to mimic the browser behaviour (the buffer eviction algorithm is starting after the browser detects that video buffer size reaches a limit in bytes)

Example for maxBufferLengthand maxMaxBufferLength. Demo here

<!DOCTYPE html>
<html lang='en' dir='ltr'>

<head>
  <meta charset='utf-8'>
  <title></title>
  <meta name='viewport' content='width=device-width,initial-scale=1'>

  <link href='https://sdk.uiza.io/v5/release/uiza.css' rel='stylesheet'>
  <script src='https://sdk.uiza.io/v5/release/uiza.min.js'></script>

</head>

<body>
  <video id='playerUz' crossorigin playsinline autoplay></video>

  <script>
    var videoStreamURL = 'https://1955897154.rsc.cdn77.org/live/116881ad-3463-4209-b16f-50e0e48add10/master.m3u8?cm=eyJlbnRpdHlfaWQiOiI2ZWUyMzk5NS1mNGFhLTQ1ZDMtOTM5NS0xN2NlNjBlZWJjNDAiLCJlbnRpdHlfc291cmNlIjoibGl2ZSIsImFwcF9pZCI6IjkyYThkMjAzMmZlODQ5MmFhNzc4MDRiNGMyYzUxOWM1In0=';

    ((options) => {
      window.UZplayer = new Uiza(document.getElementById('playerUz'), options);
    })({
      buffer: {
        maxBufferLength: 10,
        maxMaxBufferLength: 60
      },
      src: videoStreamURL
    });
  </script>

</body>

</html>

Customizing the UI button

AttributeDefaultDescription
restarttrueOnly for VOD, Set the value to false to disable restart button on the video player
rewindtrueOnly for VOD, Set the value to false to disable rewind button on the video player
playtrueSet the value to false to disable play button on the video player. Remember: should autoplay on video tag
mutetrueSet the value to false to disable mute button on the video player
volumetrueSet the value to false to disable volume button on the video player
currentTimetrueSet the value to false to hide the current time on the video player
toggleLiveViewertrueSet the value to false to hide the viewer count on the video player
progresstrueSet the value to false to hide the progress bar on the video player
fastForwardtrueSet the value to false to disable the fast forward button on the video player
captionstrueSet the value to false to disable the captions button on the video player
settingstrueSet the value to false to disable the settings button on the video player
piptrueSet the value to false to disable the picture-in-picture button on the video player
livetrueSet the value to false to hide the live button on the video player
fullscreentrueSet the value to false to disable the fullscreen button on the video player
speedtrueSet the value to false to disable the speed button on the video player
ui: {
    restart: true,
    rewind: true,
    play: true,
    mute: true,
    volume: true,
    currentTime: true,
    toggleLiveViewer: true,
    fastForward: true,
    progress: true,
    captions: true,
    settings: true,
    pip: true,
    live: true,
    fullscreen: true,
    speed: true
}

Example for hide button pip and settings, only override configure to false. Demo here

<!DOCTYPE html>
<html lang='en' dir='ltr'>

<head>
  <meta charset='utf-8'>
  <title></title>
  <meta name='viewport' content='width=device-width,initial-scale=1'>

  <link href='https://sdk.uiza.io/v5/release/uiza.css' rel='stylesheet'>
  <script src='https://sdk.uiza.io/v5/release/uiza.min.js'></script>

</head>

<body>
  <video id='playerUz' crossorigin playsinline autoplay muted></video>

  <script>
    var videoStreamURL = 'https://1955897154.rsc.cdn77.org/live/116881ad-3463-4209-b16f-50e0e48add10/master.m3u8?cm=eyJlbnRpdHlfaWQiOiI2ZWUyMzk5NS1mNGFhLTQ1ZDMtOTM5NS0xN2NlNjBlZWJjNDAiLCJlbnRpdHlfc291cmNlIjoibGl2ZSIsImFwcF9pZCI6IjkyYThkMjAzMmZlODQ5MmFhNzc4MDRiNGMyYzUxOWM1In0=';

    ((options) => {
      window.UZplayer = new Uiza(document.getElementById('playerUz'), options);
    })({
      ui: {
        pip: false,
        settings: false
      }, 
      src: videoStreamURL
    });
  </script>

</body>

</html>

Customizing the CSS

If you want to change any design tokens used for the rendering of the player, you can do so using CSS Custom Properties.

Here's a list of the properties and what they are used for:

NameDescriptionDefault / Fallback
--uiza-color-mainThe primary UI color.#f03c15 #00b3ff
--uiza-tab-focus-colorThe color used for the dotted outline when an element is :focus-visible (equivalent) keyboard focus.--uiza-color-main
--uiza-badge-backgroundThe background color for badges in the menu.#4a5464 #4a5464
--uiza-badge-text-colorThe text color for badges.#ffffff #ffffff
--uiza-badge-border-radiusThe border radius used for badges.2px
--uiza-tab-focus-colorThe color used to highlight tab (keyboard) focus.--uiza-color-main
--uiza-captions-backgroundThe color for the background of captions.rgba(0, 0, 0, 0.8)
--uiza-captions-text-colorThe color used for the captions text.#ffffff #ffffff
--uiza-control-icon-sizeThe size of the icons used in the controls.18px
--uiza-control-spacingThe space between controls (sometimes used in a multiple - e.g. 10px / 2 = 5px).10px
--uiza-control-paddingThe padding inside controls.--uiza-control-spacing * 0.7 (7px)
--uiza-control-radiusThe border radius used on controls.3px
--uiza-control-toggle-checked-backgroundThe background color used for checked menu items.--uiza-color-main
--uiza-video-controls-backgroundThe background for the video controls.linear-gradient(rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.75))
--uiza-video-control-colorThe text/icon color for video controls.#ffffff #ffffff
--uiza-video-control-color-hoverThe text/icon color used when video controls are :hover, :focus and :focus-visible (equivalent).#ffffff #ffffff
--uiza-video-control-background-hoverThe background color used when video controls are :hover, :focus and :focus-visible (equivalent).--uiza-color-main
--uiza-audio-controls-backgroundThe background for the audio controls.#ffffff #ffffff
--uiza-audio-control-colorThe text/icon color for audio controls.#4a5464 #4a5464
--uiza-audio-control-color-hoverThe text/icon color used when audio controls are :hover, :focus and :focus-visible (equivalent).#ffffff #ffffff
--uiza-audio-control-background-hoverThe background color used when video controls are :hover, :focus and :focus-visible (equivalent).--uiza-color-main
--uiza-menu-backgroundThe background color for menus.rgba(255, 255, 255, 0.9)
--uiza-menu-colorThe text/icon color for menu items.#4a5464 #4a5464
--uiza-menu-shadowThe shadow used on menus.0 1px 2px rgba(0, 0, 0, 0.15)
--uiza-menu-radiusThe border radius on the menu.4px
--uiza-menu-arrow-sizeThe size of the arrow on the bottom of the menu.6px
--uiza-menu-item-arrow-colorThe color of the arrows in the menu.#728197 #728197
--uiza-menu-item-arrow-sizeThe size of the arrows in the menu.4px
--uiza-menu-border-colorThe border color for the bottom of the back button in the top of the sub menu pages.#dcdfe5 #dcdfe5
--uiza-menu-border-shadow-colorThe shadow below the border of the back button in the top of the sub menu pages.#ffffff #ffffff
--uiza-progress-loading-sizeThe size of the stripes in the loading state in the scrubber.25px
--uiza-progress-loading-backgroundThe background color on the loading state in the scrubber.rgba(35, 40, 47, 0.6)
--uiza-video-progress-buffered-backgroundThe fill color for the buffer indication in the scrubber for video.rgba(255, 255, 255, 0.25)
--uiza-audio-progress-buffered-backgroundThe fill color for the buffer indication in the scrubber for audio.rgba(193, 200, 209, 0.6)
--uiza-range-thumb-heightThe height of the scrubber handle/thumb.13px
--uiza-range-thumb-backgroundThe background of the scrubber handle/thumb.#ffffff #ffffff
--uiza-range-thumb-shadowThe shadow of the scrubber handle/thumb.0 1px 1px rgba(215, 26, 18, 0.15), 0 0 0 1px rgba(215, 26, 18, 0.2)
--uiza-range-thumb-active-shadow-widthThe width of the shadow when the scrubber handle/thumb is :active (pressed).3px
--uiza-range-track-heightThe height of the scrubber/progress track.5px
--uiza-range-fill-backgroundThe fill color of the scrubber/progress.--uiza-color-main
--uiza-video-range-track-backgroundThe background of the scrubber/progress.--uiza-video-progress-buffered-background
--uiza-video-range-thumb-active-shadow-colorThe color of the shadow when the video scrubber handle/thumb is :active (pressed).rgba(255, 255, 255, 0.5)
--uiza-audio-range-track-backgroundThe background of the scrubber/progress.--uiza-video-progress-buffered-background
--uiza-audio-range-thumb-active-shadow-colorThe color of the shadow when the audio scrubber handle/thumb is :active (pressed).rgba(215, 26, 18, 0.1)
--uiza-tooltip-backgroundThe background color for tooltips.rgba(255, 255, 255, 0.9)
--uiza-tooltip-colorThe text color for tooltips.#4a5464 #4a5464
--uiza-tooltip-paddingThe padding for tooltips.calc(var(--uiza-control-spacing) / 2))
--uiza-tooltip-arrow-sizeThe size of the arrow under tooltips.4px
--uiza-tooltip-radiusThe border radius on tooltips.3px
--uiza-tooltip-shadowThe shadow on tooltips.0 1px 2px rgba(0, 0, 0, 0.15)
--uiza-font-familyThe font family used in the player.
--uiza-font-size-baseThe base font size. Mainly used for captions.15px
--uiza-font-size-smallThe smaller font size. Mainly used for captions.13px
--uiza-font-size-largeThe larger font size. Mainly used for captions.18px
--uiza-font-size-xlargeThe even larger font size. Mainly used for captions.21px
--uiza-font-size-timeThe font size for the time.--uiza-font-size-small
--uiza-font-size-menuThe font size used in the menu.--uiza-font-size-small
--uiza-font-size-badgeThe font size used for badges.9px
--uiza-font-weight-regularThe regular font weight.400
--uiza-font-weight-boldThe bold font weight.600
--uiza-line-heightThe line height used within the player.1.7
--uiza-font-smoothingWhether to enable font antialiasing within the player.false

You can set them in your CSS for all players:

:root {
  --uiza-color-main: #1ac266;
}

...or for a specific class name:

.player {
  --uiza-color-main: #1ac266;
}

...or in your HTML:

<video class="player" style="--uiza-color-main: #1ac266;">
    ...
</vieo>

Cross Origin (CORS)

You'll notice the crossorigin attribute on the example <video> elements. This is because the TextTrack captions are loaded from another domain. If your TextTrack captions are also hosted on another domain, you will need to add this attribute and make sure your host has the correct headers setup. For more info on CORS checkout the MDN docs: https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS

Captions

WebVTT captions are supported. To add a caption track, check the HTML example above and look for the <track> element. Be sure to validate your caption files.

JavaScript

Initialising

You can specify a range of arguments for the constructor to use:

Note: If a NodeList, Array, or jQuery object are passed, the first element will be used for setup. To setup multiple players, see multiple players below.

Single player

Passing a CSS string selector that's compatible with querySelector:

const player = new Uiza('#playerUz');

Passing a HTMLElement:

const player = new Uiza(document.getElementById('playerUz'));
const player = new Uiza(document.querySelector('.js-player'));

The HTMLElement or string selector can be the target <video>, <audio>, or <div> wrapper for embeds.

Multiple players

You have two choices here. You can either use a simple array loop to map the constructor:

const players = Array.from(document.querySelectorAll('.js-player')).map(p => new Uiza(p));

...or use a static method where you can pass a CSS string selector, a NodeList, an Array of HTMLElement, or a JQuery object:

const players = Uiza.setup('.js-player');

Both options will also return an array of instances in the order of they were in the DOM for the string selector or the source NodeList or Array.

Options

The second argument for the constructor is the options object:

const player = new Uiza('#playerUz', {
  title: 'Example Title',
});

Options can be passed as an object to the constructor as above or as JSON in data-uiza-config attribute on each of your target elements:

<video src="/path/to/video.mp4" id="playerUz" controls data-uiza-config='{ "title": "Example Title" }'></video>

Note the single quotes encapsulating the JSON and double quotes on the object keys. Only string values need double quotes.

OptionTypeDefaultDescription
enabledBooleantrueCompletely disable Uiza. This would allow you to do a User Agent check or similar to programmatically enable or disable Uiza for a certain UA. Example below.
debugBooleanfalseDisplay debugging information in the console
controlsArray, Function or Element['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen']If a function is passed, it is assumed your method will return either an element or HTML string for the controls. Three arguments will be passed to your function; id (the unique id for the player), seektime (the seektime step in seconds), and title (the media title). See CONTROLS.md for more info on how the html needs to be structured.
settingsArray['captions', 'quality', 'speed', 'loop']If the default controls are used, you can specify which settings to show in the menu
i18nObjectSee defaults.jsUsed for internationalization (i18n) of the text within the UI.
loadSpriteBooleantrueLoad the SVG sprite specified as the iconUrl option (if a URL). If false, it is assumed you are handling sprite loading yourself.
iconUrlStringnullSpecify a URL or path to the SVG sprite. See the SVG section for more info.
iconPrefixStringuizaSpecify the id prefix for the icons used in the default controls (e.g. "uiza-play" would be "uiza"). This is to prevent clashes if you're using your own SVG sprite but with the default controls. Most people can ignore this option.
blankVideoStringhttps://cdn.Uiza.io/static/blank.mp4Specify a URL or path to a blank video file used to properly cancel network requests.
autoplay²BooleanfalseAutoplay the media on load. If the autoplay attribute is present on a <video> or <audio> element, this will be automatically set to true.
autopause¹BooleantrueOnly allow one player playing at once.
seekTimeNumber10The time, in seconds, to seek when a user hits fast forward or rewind.
volumeNumber1A number, between 0 and 1, representing the initial volume of the player.
mutedBooleanfalseWhether to start playback muted. If the muted attribute is present on a <video> or <audio> element, this will be automatically set to true.
clickToPlayBooleantrueClick (or tap) of the video container will toggle play/pause.
disableContextMenuBooleantrueDisable right click menu on video to help as very primitive obfuscation to prevent downloads of content.
hideControlsBooleantrueHide video controls automatically after 2s of no mouse or focus movement, on control element blur (tab out), on playback start or entering fullscreen. As soon as the mouse is moved, a control element is focused or playback is paused, the controls reappear instantly.
resetOnEndBooleanfalseReset the playback to the start once playback is complete.
keyboardObject{ focused: true, global: false }Enable keyboard shortcuts for focused players only or globally
tooltipsObject{ controls: false, seek: true }controls: Display control labels as tooltips on :hover & :focus (by default, the labels are screen reader only). seek: Display a seek tooltip to indicate on click where the media would seek to.
durationNumbernullSpecify a custom duration for media.
displayDurationBooleantrueDisplays the duration of the media on the "metadataloaded" event (on startup) in the current time display. This will only work if the preload attribute is not set to none (or is not set at all) and you choose not to display the duration (see controls option).
invertTimeBooleantrueDisplay the current time as a countdown rather than an incremental counter.
toggleInvertBooleantrueAllow users to click to toggle the above.
listenersObjectnullAllows binding of event listeners to the controls before the default handlers. See the defaults.js for available listeners. If your handler prevents default on the event (event.preventDefault()), the default handler will not fire.
captionsObject{ active: false, language: 'auto', update: false }active: Toggles if captions should be active by default. language: Sets the default language to load (if available). 'auto' uses the browser language. update: Listen to changes to tracks and update menu. This is needed for some streaming libraries, but can result in unselectable language options).
fullscreenObject{ enabled: true, fallback: true, iosNative: false, container: null }enabled: Toggles whether fullscreen should be enabled. fallback: Allow fallback to a full-window solution (true/false/'force'). iosNative: whether to use native iOS fullscreen when entering fullscreen (no custom controls). container: A selector for an ancestor of the player element, allows contextual content to remain visual in fullscreen mode. Non-ancestors are ignored.
ratioStringnullForce an aspect ratio for all videos. The format is 'w:h' - e.g. '16:9' or '4:3'. If this is not specified then the default for HTML5 and Vimeo is to use the native resolution of the video. As dimensions are not available from YouTube via SDK, 16:9 is forced as a sensible default.
storageObject{ enabled: true, key: 'uiza' }enabled: Allow use of local storage to store user settings. key: The key name to use.
speedObject{ selected: 1, options: [0.5, 0.75, 1, 1.25, 1.5, 1.75, 2] }selected: The default speed for playback. options: The speed options to display in the UI. YouTube and Vimeo will ignore any options outside of the 0.5-2 range, so options outside of this range will be hidden automatically.
qualityObject{ default: 576, options: [4320, 2880, 2160, 1440, 1080, 720, 576, 480, 360, 240] }default is the default quality level (if it exists in your sources). options are the options to display. This is used to filter the available sources.
loopObject{ active: false }active: Whether to loop the current video. If the loop attribute is present on a <video> or <audio> element, this will be automatically set to true This is an object to support future functionality.
urlsObjectSee source.If you wish to override any API URLs then you can do so here. You can also set a custom download URL for the download button.
previewThumbnailsObject{ enabled: false, src: '' }enabled: Whether to enable the preview thumbnails (they must be generated by you). src must be either a string or an array of strings representing URLs for the VTT files containing the image URL(s). Learn more about preview thumbnails below.

API

There are methods, setters and getters on a Uiza object.

Object

The easiest way to access the Uiza object is to set the return value from your call to the constructor to a variable. For example:

const player = new Uiza('#player', {
  /* options */
});

You can also access the object through any events:

element.addEventListener('ready', event => {
  const player = event.detail.uiza;
});

Methods

Example method use:

player.play(); // Start playback
player.fullscreen.enter(); // Enter fullscreen
MethodParametersDescription
play()¹-Start playback.
pause()-Pause playback.
togglePlay(toggle)¹BooleanToggle playback, if no parameters are passed, it will toggle based on current status.
stop()-Stop playback and reset to start.
restart()-Restart playback.
rewind(seekTime)NumberRewind playback by the specified seek time. If no parameter is passed, the default seek time will be used.
forward(seekTime)NumberFast forward by the specified seek time. If no parameter is passed, the default seek time will be used.
increaseVolume(step)NumberIncrease volume by the specified step. If no parameter is passed, the default step will be used.
decreaseVolume(step)NumberIncrease volume by the specified step. If no parameter is passed, the default step will be used.
toggleCaptions(toggle)BooleanToggle captions display. If no parameter is passed, it will toggle based on current status.
fullscreen.enter()-Enter fullscreen. If fullscreen is not supported, a fallback "full window/viewport" is used instead.
fullscreen.exit()-Exit fullscreen.
fullscreen.toggle()-Toggle fullscreen.
airplay()-Trigger the airplay dialog on supported devices.
toggleControls(toggle)BooleanToggle the controls (video only). Takes optional truthy value to force it on/off.
on(event, function)String, FunctionAdd an event listener for the specified event.
once(event, function)String, FunctionAdd an event listener for the specified event once.
off(event, function)String, FunctionRemove an event listener for the specified event.
supports(type)StringCheck support for a mime type.
destroy()-Destroy the instance and garbage collect any elements.
  1. For HTML5 players, play() will return a Promise for most browsers - e.g. Chrome, Firefox, Opera, Safari and Edge according to MDN at time of writing.

Getters and Setters

Example setters:

player.volume = 0.5; // Sets volume at 50%
player.currentTime = 10; // Seeks to 10 seconds

Example getters:

player.volume; // 0.5;
player.currentTime; // 10
player.fullscreen.active; // false;
PropertyGetterSetterDescription
isHTML5-Returns a boolean indicating if the current player is HTML5.
isEmbed-Returns a boolean indicating if the current player is an embedded player.
playing-Returns a boolean indicating if the current player is playing.
paused-Returns a boolean indicating if the current player is paused.
stopped-Returns a boolean indicating if the current player is stopped.
ended-Returns a boolean indicating if the current player has finished playback.
buffered-Returns a float between 0 and 1 indicating how much of the media is buffered
currentTimeGets or sets the currentTime for the player. The setter accepts a float in seconds.
seeking-Returns a boolean indicating if the current player is seeking.
duration-Returns the duration for the current media.
volumeGets or sets the volume for the player. The setter accepts a float between 0 and 1.
mutedGets or sets the muted state of the player. The setter accepts a boolean.
hasAudio-Returns a boolean indicating if the current media has an audio track.
speedGets or sets the speed for the player. The setter accepts a value in the options specified in your config. Generally the minimum should be 0.5.
quality¹Gets or sets the quality for the player. The setter accepts a value from the options specified in your config.
loopGets or sets the current loop state of the player. The setter accepts a boolean.
sourceGets or sets the current source for the player. The setter accepts an object. See source setter below for examples.
posterGets or sets the current poster image for the player. The setter accepts a string; the URL for the updated poster image.
autoplayGets or sets the autoplay state of the player. The setter accepts a boolean.
currentTrackGets or sets the caption track by index. -1 means the track is missing or captions is not active
languageGets or sets the preferred captions language for the player. The setter accepts an ISO two-letter language code. Support for the languages is dependent on the captions you include. If your captions don't have any language data, or if you have multiple tracks with the same language, you may want to use currentTrack instead.
fullscreen.active-Returns a boolean indicating if the current player is in fullscreen mode.
fullscreen.enabled-Returns a boolean indicating if the current player has fullscreen enabled.
pip¹Gets or sets the picture-in-picture state of the player. The setter accepts a boolean. This currently only supported on Safari 10+ (on MacOS Sierra+ and iOS 10+) and Chrome 70+.
ratioGets or sets the video aspect ratio. The setter accepts a string in the same format as the ratio option.
downloadGets or sets the URL for the download button. The setter accepts a string containing a valid absolute URL.
  1. HTML5 only

Note: src property for YouTube and Vimeo can either be the video ID or the whole URL.

PropertyTypeDescription
typeStringEither video or audio.
titleStringOptional. Title of the new media. Used for the aria-label attribute on the play button, and outer container. YouTube and Vimeo are populated automatically.
sourcesArrayThis is an array of sources. For HTML5 media, the properties of this object are mapped directly to HTML attributes so more can be added to the object if required.
poster¹StringThe URL for the poster image (HTML5 video only).
tracks¹StringAn array of track objects. Each element in the array is mapped directly to a track element and any keys mapped directly to HTML attributes so as in the example above, it will render as <track kind="captions" label="English" srclang="en" src="https://cdn.selz.com/uiza/1.0/example_captions_en.vtt" default> and similar for the French version. Booleans are converted to HTML5 value-less attributes.
previewThumbnails¹ObjectThe same object like in the previewThumbnails constructor option. This means you can either change the thumbnails vtt via the src key or disable the thumbnails plugin for the next video by passing { enabled: false }.
  1. HTML5 only

Events

You can listen for events on the target element you setup Uiza on (see example under the table). Some events only apply to HTML5 audio and video. Using your reference to the instance, you can use the on() API method or addEventListener(). Access to the API can be obtained this way through the event.detail.uiza property. Here's an example:

player.on('ready', event => {
  const instance = event.detail.uiza;
});

Standard Media Events

Event TypeDescription
progressSent periodically to inform interested parties of progress downloading the media. Information about the current amount of the media that has been downloaded is available in the media element's buffered attribute.
playingSent when the media begins to play (either for the first time, after having been paused, or after ending and then restarting).
playSent when playback of the media starts after having been paused; that is, when playback is resumed after a prior pause event.
pauseSent when playback is paused.
timeupdateThe time indicated by the element's currentTime attribute has changed.
volumechangeSent when the audio volume changes (both when the volume is set and when the muted state is changed).
seekingSent when a seek operation begins.
seekedSent when a seek operation completes.
ratechangeSent when the playback speed changes.
endedSent when playback completes. Note: This does not fire if autoplay is true.
enterfullscreenSent when the player enters fullscreen mode (either the proper fullscreen or full-window fallback for older browsers).
exitfullscreenSent when the player exits fullscreen mode.
captionsenabledSent when captions are enabled.
captionsdisabledSent when captions are disabled.
languagechangeSent when the caption language is changed.
controlshiddenSent when the controls are hidden.
controlsshownSent when the controls are shown.
readyTriggered when the instance is ready for API calls.
5.20.8-rc2

4 years ago

5.20.8-rc1

4 years ago

5.20.7-rc11

4 years ago

5.20.7-rc9

4 years ago

5.20.7-rc10

4 years ago

5.20.7-rc8

4 years ago

5.20.7-rc7

4 years ago

5.20.7-rc6

4 years ago

5.20.7-rc5

4 years ago

5.20.7-rc4

4 years ago

5.20.7-rc3

4 years ago

5.20.7-rc1

4 years ago

5.20.6-rc6

4 years ago

5.20.6-rc4

4 years ago

5.20.6-rc3

4 years ago

5.20.707

4 years ago

5.20.6-rc2

4 years ago

5.20.6-rc1

4 years ago

5.20.705

4 years ago

5.20.6-staging

4 years ago

5.20.704

4 years ago

5.20.703

4 years ago

5.20.702

4 years ago

5.20.701

4 years ago