1.0.0 โ€ข Published 10 months ago

km-plyr v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago
๐ŸŽ‰Plyr is merging into Vidstack๐ŸŽ‰

Plyr is a simple, lightweight, accessible and customizable HTML5, YouTube and Vimeo media player that supports modern browsers.

Checkout the demo - Donate - Slack

npm version Gitpod Ready-to-Code Financial Contributors on Open Collective

Screenshot of Plyr

Features

  • ๐Ÿ“ผ HTML Video & Audio, YouTube & Vimeo - support for the major formats
  • ๐Ÿ’ช Accessible - full support for VTT captions and screen readers
  • ๐Ÿ”ง Customizable - make the player look how you want with the markup you want
  • ๐Ÿ˜Ž Clean HTML - uses the right elements. <input type="range"> for volume and <progress> for progress and well, <button>s for buttons. There's no <span> or <a href="#"> button hacks
  • ๐Ÿ“ฑ Responsive - works with any screen size
  • ๐Ÿ’ต Monetization - make money from your videos
  • ๐Ÿ“น Streaming - support for hls.js, Shaka and dash.js streaming playback
  • ๐ŸŽ› API - toggle playback, volume, seeking, and more through a standardized API
  • ๐ŸŽค Events - no messing around with Vimeo and YouTube APIs, all events are standardized across formats
  • ๐Ÿ”Ž Fullscreen - supports native fullscreen with fallback to "full window" modes
  • โŒจ๏ธ Shortcuts - supports keyboard shortcuts
  • ๐Ÿ–ฅ Picture-in-Picture - supports picture-in-picture mode
  • ๐Ÿ“ฑ Playsinline - supports the playsinline attribute
  • ๐ŸŽ Speed controls - adjust speed on the fly
  • ๐Ÿ“– Multiple captions - support for multiple caption tracks
  • ๐ŸŒŽ i18n support - support for internationalization of controls
  • ๐Ÿ‘Œ Preview thumbnails - support for displaying preview thumbnails
  • ๐ŸคŸ No frameworks - written in "vanilla" ES6 JavaScript, no jQuery required
  • ๐Ÿ’โ€โ™€๏ธ Sass - to include in your build processes

Demos

You can try Plyr in Codepen using our minimal templates: HTML5 video, HTML5 audio, YouTube, Vimeo. For Streaming we also have example integrations with: Dash.js, Hls.js and Shaka Player

Quick setup

HTML

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

HTML5 Video

<video id="player" playsinline controls data-poster="/path/to/poster.jpg">
  <source src="/path/to/video.mp4" type="video/mp4" />
  <source src="/path/to/video.webm" type="video/webm" />

  <!-- Captions are optional -->
  <track kind="captions" label="English captions" src="/path/to/captions.vtt" srclang="en" default />
</video>

Note: The poster image should be specified using data-poster. This is to prevent it being downloaded twice. If you're sure the image will be cached, you can still use the poster attribute for true progressive enhancement.

HTML5 Audio

<audio id="player" controls>
  <source src="/path/to/audio.mp3" type="audio/mp3" />
  <source src="/path/to/audio.ogg" type="audio/ogg" />
</audio>

For YouTube and Vimeo players, Plyr uses progressive enhancement to enhance the default <iframe> embeds. Below are some examples. The plyr__video-embed classname will make the embed responsive. You can add the autoplay, loop, hl (YouTube only) and playsinline (YouTube only) query parameters to the URL and they will be set as config options automatically. For YouTube, the origin should be updated to reflect the domain you're hosting the embed on, or you can opt to omit it.

YouTube

We recommend progressive enhancement with the embedded players. You can elect to use an <iframe> as the source element (which Plyr will progressively enhance) or a bog standard <div> with two essential data attributes - data-plyr-provider and data-plyr-embed-id.

<div class="plyr__video-embed" id="player">
  <iframe
    src="https://www.youtube.com/embed/bTqVqk7FSmY?origin=https://plyr.io&amp;iv_load_policy=3&amp;modestbranding=1&amp;playsinline=1&amp;showinfo=0&amp;rel=0&amp;enablejsapi=1"
    allowfullscreen
    allowtransparency
    allow="autoplay"
  ></iframe>
</div>

Note: The plyr__video-embed classname will make the player a responsive 16:9 (most common) iframe embed. When plyr itself kicks in, your custom ratio config option will be used.

Or the <div> non progressively enhanced method:

<div id="player" data-plyr-provider="youtube" data-plyr-embed-id="bTqVqk7FSmY"></div>

Note: The data-plyr-embed-id can either be the video ID or URL for the media.

Vimeo

Much the same as YouTube above.

<div class="plyr__video-embed" id="player">
  <iframe
    src="https://player.vimeo.com/video/76979871?loop=false&amp;byline=false&amp;portrait=false&amp;title=false&amp;speed=true&amp;transparent=0&amp;gesture=media"
    allowfullscreen
    allowtransparency
    allow="autoplay"
  ></iframe>
</div>

Or the <div> non progressively enhanced method:

<div id="player" data-plyr-provider="vimeo" data-plyr-embed-id="76979871"></div>

JavaScript

You can use Plyr as an ES6 module as follows:

import Plyr from 'plyr';

const player = new Plyr('#player');

Alternatively you can include the plyr.js script before the closing </body> tag and then in your JS create a new instance of Plyr as below.

<script src="path/to/plyr.js"></script>
<script>
  const player = new Plyr('#player');
</script>

See initialising for more information on advanced setups.

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

<script src="https://cdn.plyr.io/3.7.8/plyr.js"></script>

...or...

<script src="https://cdn.plyr.io/3.7.8/plyr.polyfilled.js"></script>

CSS

Include the plyr.css stylesheet into your <head>.

<link rel="stylesheet" href="path/to/plyr.css" />

If you want to use our CDN (provided by Cloudflare) for the default CSS, you can use the following:

<link rel="stylesheet" href="https://cdn.plyr.io/3.7.8/plyr.css" />

SVG Sprite

The SVG sprite is loaded automatically from our CDN (provided by Cloudflare). To change this, see the options below. For reference, the CDN hosted SVG sprite can be found at https://cdn.plyr.io/3.7.8/plyr.svg.

Self hosting

If you don't want to create a build system to include Plyr as an npm module, you can use the pre-built files. You have a few options:

  • Download the files from the CDN links above, they're already minified.
  • Download the files from unpkg or similar services.
  • Build the project yourself using npm i && npm run build, which installs the dependencies and spits out a build to dist.

Ads

Plyr has partnered up with vi.ai to offer monetization options for your videos. Getting setup is easy:

Any questions regarding the ads can be sent straight to vi.ai and any issues with rendering raised through GitHub issues.

If you do not wish to use Vi, you can set your own ads.tagUrl option.

Advanced

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

You can set them in your CSS for all players:

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

...or for a specific class name:

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

...or in your HTML:

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

Sass

You can use plyr.scss file included in /src/sass as part of your build and change variables to suit your design. The Sass requires you to use autoprefixer (you should be already!) as all declarations use the W3C definitions.

The HTML markup uses the BEM methodology with plyr as the block, e.g. .plyr__controls. You can change the class hooks in the options to match any custom CSS you write. Check out the JavaScript source for more on this.

SVG

The icons used in the Plyr controls are loaded in an SVG sprite. The sprite is automatically loaded from our CDN by default. If you already have an icon build system in place, you can include the source plyr icons (see /src/sprite for source icons).

Using the iconUrl option

You can however specify your own iconUrl option and Plyr will determine if the url is absolute and requires loading by AJAX/CORS due to current browser limitations or if it's a relative path, just use the path directly.

If you're using the <base> tag on your site, you may need to use something like this: svgfixer.js

More info on SVG sprites here: http://css-tricks.com/svg-sprites-use-better-icon-fonts/ and the AJAX technique here: http://css-tricks.com/ajaxing-svg-sprite/

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

Initializing

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 Plyr('#player');

Passing a HTMLElement:

const player = new Plyr(document.getElementById('player'));
const player = new Plyr(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 Plyr(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 = Plyr.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 Plyr('#player', {
  title: 'Example Title',
});

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

<video src="/path/to/video.mp4" id="player" controls data-plyr-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 Plyr. This would allow you to do a User Agent check or similar to programmatically enable or disable Plyr 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.
iconPrefixStringplyrSpecify the id prefix for the icons used in the default controls (e.g. "plyr-play" would be "plyr"). 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.plyr.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.
playsinlineยณBooleantrueAllow inline playback on iOS. Note this has no effect on iPadOS.
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 non-selectable 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) - note this has no effect on iPadOS. 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: 'plyr' }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, 4] }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.
adsObject{ enabled: false, publisherId: '', tagUrl: '' }enabled: Whether to enable advertisements. publisherId: Your unique vi.ai publisher ID. tagUrl is a URL for a custom VAST tag if you're not using Vi.
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.
vimeoObject{ byline: false, portrait: false, title: false, speed: true, transparent: false }See Vimeo embed options. Some are set automatically based on other config options, namely: loop, autoplay, muted, gesture, playsinline
youtubeObject{ noCookie: false, rel: 0, showinfo: 0, iv_load_policy: 3, modestbranding: 1 }See YouTube embed options. The only custom option is noCookie to use an alternative to YouTube that doesn't use cookies (useful for GDPR, etc). Some are set automatically based on other config options, namely: autoplay, hl, controls, disablekb, playsinline, cc_load_policy, cc_lang_pref, widget_referrer
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.
mediaMetadataObject{ title: '', artist: '', album: '', artwork: [] }The MediaMetadata interface of the Media Session API allows a web page to provide rich media metadata for display in a platform UI.
markersObject{ enabled: false, points: [] }enabled: Whether to enable markers. points is an array of { time: number; label: string; } objects where time represents the marker position in seconds and label is the HTML string to be displayed.
  1. Vimeo only
  2. Autoplay is generally not recommended as it is seen as a negative user experience. It is also disabled in many browsers. Before raising issues, do your homework. More info can be found here:
  1. YouTube does not support programatically toggling the native fullscreen player via it's API. This means on iOS you have two options, neither being perfect:
  • Use the fallback/faux fullscreen option which covers the whole viewport (this is the default)
  • Set playsinline to false and/or fullscreen.iosNative to true - either option hides the fullscreen toggle in the UI (because of the above API issue) and means iOS will play the video in it's native player.

API

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

Object

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

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

You can also access the object through any events:

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

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.
setPreviewThumbnails(source: PreviewThumbnailsOptions)-Sets the preview thumbnails for the current source.
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
currentTimeโœ“โœ“Gets 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.
volumeโœ“โœ“Gets or sets the volume for the player. The setter accepts a float between 0 and 1.
mutedโœ“โœ“Gets or sets the muted state of the player. The setter accepts a boolean.