Loading repository data…
Loading repository data…
vlitejs / repository
🦋 vLitejs is a fast and lightweight Javascript library for customizing video and audio player in Javascript with a minimalist theme (HTML5, Youtube, Vimeo, Dailymotion)
vlitejs (pronounced /viːlaɪt/) is a fast and lightweight JavaScript library for customizing video and audio player. Written in native JavaScript without dependency, it is built around an API of providers and plugins to extend these capabilities and keep the core with the minimal functionalities.
HTML5 video and audio players are automatically included. Other providers like Youtube or Vimeo can be loaded on demand with the Provider API. Plugins uses the same logic and can be loaded on demand by the Plugin API. Others providers and plugins can be created and loaded by the library.
Sizes of the vlitejs bundle compared to the competition:
vlitejs | plyr | video.js | |
|---|---|---|---|
| Uncompressed | 68 KB | 299 KB | 2100 KB |
| Compressed | 27 KB | 110 KB | 560 KB |
| Gzip | 6 KB | 32 KB | 159 KB |
[!NOTE]
vlitejs 5.0.1plyr 3.7.8videojs 8.3.0
:sparkles: You can support this project with GitHub Sponsors! ♡
If you're interested in playing around with vLitejs, you can use the online code playgrounds on Glitch:
The project includes several examples of vlitejs implementation in the directory examples. Run the following commands to build the assets for the examples:
npm run build && npm run build:example
[!WARNING] vlitejs@6 is ESM and uses the Node.js package
exports.
NPM is the recommended installation method. Install vlitejs in your project with the following command:
npm install vlitejs --save-dev
yarn add vlitejs --dev
[!WARNING] The minimum supported
Node.jsversion is22.
You can also download it and include it with a script tag as an ESM.
<link href="https://cdn.jsdelivr.net/npm/vlitejs@6/dist/vlite.css" rel="stylesheet" crossorigin />
<script type="module">
import Vlitejs from 'https://cdn.jsdelivr.net/npm/vlitejs@6';
</script>
[!TIP] You can browse the source of the NPM package at jsdelivr.com/package/npm/vlitejs.
<video id="player" src="<path_to_video_mp4>"></video>
<audio id="player" src="<path_to_audio_mp3>"></audio>
<div id="player" data-youtube-id="<video_id>"></div>
<div id="player" data-vimeo-id="<video_id>"></div>
<div id="player" data-dailymotion-id="<video_id>"></div>
Import vlitejs styleheet and the JavaScript library as an ES6 modules.
import 'vlitejs/vlite.css';
import Vlitejs from 'vlitejs';
The vlitejs constructor accepts the following parameters:
| Arguments | Type | Default | Description |
|---|---|---|---|
| selector | String|HTMLElement | null | Unique CSS selector string or HTMLElement to target the player |
| config | Object | {} | Player configuration (optional) |
Initialize the player with a CSS selector string.
new Vlitejs('#player');
Or, initialize the player with an HTMLElement.
new Vlitejs(document.querySelector('#player'));
The second arguments of the contructor is an optional object with the following parameters:
| Arguments | Type | Default | Description |
|---|---|---|---|
options | Object | {} | Player options |
onReady | Function|null | null | Callback function executed when the player is ready |
provider | String | 'html5' | Player provider |
plugins | Array | [] | Player plugins |
new Vlitejs('#player', {
options: {},
onReady: function (player) {},
provider: 'html5',
plugins: []
});
The player controls can be customized with the following parameters:
| Options | Type | Default | Description |
|---|---|---|---|
controls¹ ² | Boolean | true | Display the control bar of the video |
autoplay | Boolean | false | Enable the autoplay of the media |
playPause | Boolean | true | Display the play/pause button on the control bar |
progressBar | Boolean | true | Display the progress bar on the control bar |
time | Boolean | true | Display the time information on the control bar |
volume | Boolean | true | Display the volume button on the control bar |
fullscreen¹ ⁴ | Boolean | true | Display the fullscreen button on the control bar |
poster¹ | String|null | null | Customize the video poster url |
bigPlay¹ | Boolean | true | Display the big play button on the poster video |
playsinline¹ | Boolean | true | Add the playsinline attribute to the video |
loop | Boolean | false | Whether to loop the current media |
muted¹ |
[!NOTE]
- ¹ Video only.
- ² Vimeo provider requires a Plus or Pro account to use this feature (see Vimeo plans).
- ³ See Youtube embed options and Vimeo embed options.
- ⁴ Fullscreen API not yet supported on iPhone.
The
autoplayparameter automatically activates themutedoption because the API can only be initiated by a user gesture (see Autoplay policy changes).
Example of customization for the autoHide and the
playsinline attribute.Boolean |
false |
| Whether to mute the current media |
autoHide¹ | Boolean | false | Auto hide the control bar in the event of inactivity |
autoHideDelay¹ | Integer | 3000 | Auto hide delay in millisecond |
providerParams³ | Object | {} | Overrides the player parameters of the provider |