Custom HTML5 Video/Audio And Youtube/Vimeo Players – vLite.js
The goal of this library is to make the web videos have a consistent look.
1. Install and import the vLite.js library and OPTIONAL providers & plugins as follows:
# Yarn $ yarn add vlitejs # NPM $ npm i vlitejs
// Core import './dist/vlite.css'; import Vlitejs from './dist/vlite.js'; // Youtube Provider import VlitejsYoutube from './dist/providers/youtube.js'; // Vimeo Provider import VlitejsVimeo from './dist/providers/vimeo.js'; // Dailymotion Provider import VlitejsVimeo from './dist/providers/dailymotion.js'; // Picture in Picture plugin import VlitejsPip from './dist/plugins/pip.js'; // Cast plugin import './dist/plugins/cast.css'; import VlitejsPip from './dist/plugins/cast.js'; // Subtitle plugin import './dist/plugins/subtitle.css'; import VlitejsSubtitle from './dist/plugins/subtitle.js'; // Airplay Plugin import 'vlitejs/dist/plugins/airplay.css'; import VlitejsAirPlay from 'vlitejs/dist/plugins/airplay'; // Volume bar Plugin import VlitejsVolumeBar from 'vlitejs/dist/plugins/volume-bar'; // Google IMA SDK Plugin import 'vlitejs/dist/plugins/ima.css'; import VlitejsIma from 'vlitejs/dist/plugins/ima'; // Sticky Plugin import VlitejsSticky from 'vlitejs/dist/plugins/sticky'; // Hotkey plugin import VlitejsHotkeys from 'vlitejs/plugins/hotkeys.js'; // Mobile plugin import VlitejsMobile from 'vlitejs/plugins/mobile/mobile.js';
2. Or directly load the necessary JavaScript and CSS files in the document.
<link href="dist/vlite.css" rel="stylesheet" /> <script src="dist/vlite.js"></script> <!-- Providers & Plugins Here -->
3. Initialize the vLite.js library and we’re ready to go.
new Vlitejs('#player'); 4. Embed videos & audios into your page.
<!-- HTML5 Video --> <video id="player" class="vlite-js" src="video.mp4"></video> <!-- HTML5 Audio --> <audio id="player" class="vlite-js" src="audio.mp3"></audio> <!-- Youtube Video --> <div id="player" class="vlite-js" data-youtube-id="VideoID"></div> <!-- Vimeo Video --> <div id="player" class="vlite-js" data-vimeo-id="AudioID"></div>
5. Determine the provider you want to use: html5 (default), Youtube, Vimeo, or custom provider.
Vlitejs.registerProvider('youtube', VlitejsYoutube);
Vlitejs.registerProvider('vimeo', VlitejsVimeo);
new Vlitejs('#player',{
provider: 'youtube'
}); 6. Determine the player plugins you want to use:
Vlitejs.registerPlugin('subtitle', VlitejsSubtitle)
Vlitejs.registerPlugin('pip', VlitejsPip)
new Vlitejs('#player',{
plugins: ['subtitle', 'pip']
}); 7. Available configuration options.
new Vlitejs('#player',{
options: {
// auto play
autoplay: false,
// enable controls
controls: true,
// enables play/pause buttons
playPause: true,
// shows progress bar
progressBar: true,
// shows time
time: true,
// set seek time
seekTime: 5,
// shows volume control
volume: true,
// volume step
volumeStep: 0.1,
// shows fullscreen button
fullscreen: true,
// path to poster image
poster: null,
// shows play button
bigPlay: true,
// hide the control bar if the user is inactive
autoHide: false,
// in millisecond
autoHideDelay: 3000,
// add the playsinline attribute to the video
playsinline: false,
// loop the current media
loop: false,
// mute the current media
muted: false,
// Youtube/Vimeo player parameters
providerParams: {},
}
}); 8. Trigger a function when the player is ready.
new Vlitejs('#player',{
onReady: function (player) {
player.pause()
}
}); 9. API methods.
// plays the video player.play(); // pauses the video player.pause(); // set the volume (0-1) player.setVolume(volume); // get the volume player.getVolume(); // changes the current time in seconds player.seekTo(20); // gets the current time player.getCurrentTime(); // gets the duration player.getDuration(); // mute player.mute(); // unmute player.unMmute(); // fullscreen mode player.requestFullscreen(); // exit the fullsceen mode player.exitFullscreen(); // get the player instance player.getInstance(); // set the loading status player.loading(true/false); // destroys the player player.destroy();
10. Events.
player.on('play', () => console.log('play'))
player.on('pause', () => console.log('pause'))
player.on('progress', () => console.log('progress'))
player.on('timeupdate', () => console.log('timeupdate'))
player.on('volumechange', () => console.log('volumechange'))
player.on('enterfullscreen', () => console.log('enterfullscreen'))
player.on('exitfullscreen', () => console.log('exitfullscreen'))
player.on('enterpip', () => console.log('enterpip'))
player.on('leavepip', () => console.log('leavepip'))
player.on('trackenabled', () => console.log('trackenabled'))
player.on('trackdisabled', () => console.log('trackdisabled'))
player.on('ended', () => console.log('ended')) v8.1.0 (03/17/2026)
v8.0.0 (12/15/2025)
v7.4.2 (10/13/2025)
v7.4.1 (10/13/2025)
v7.4.0 (06/11/2025)
v7.3.2 (06/11/2025)
v7.3.1 (03/05/2025)
v7.3.0 (03/05/2025)
v7.2.1 (03/03/2025)
v7.2.0 (02/24/2025)
v7.1.0 (02/20/2025)
v7.0.0 (11/28/2024)
v6.0.5 (10/23/2024)
v6.0.4 (08/27/2024)
v6.0.3 (04/02/2024)
v6.0.2 (02/14/2024)
v6.0.0 (07/04/2023)
v5.0.2 (06/26/2023)
v5.0.1 (05/03/2023)
v5.0.0 (05/01/2023)
v4.2.0 (09/09/2022)
v4.1.2 (08/16/2022)
v4.1.1 (08/11/2022)
v4.1.0 (08/11/2022)
v4.0.7 (08/03/2022)
v4.0.5 (04/05/2022)
v4.0.4 (10/24/2021)
v4.0.3 (10/23/2021)
v4.0.2 (06/22/2021)
v4.0.1 (06/18/2021)
v4.0.0 (04/17/2021)
12/21/2019
12/11/2019
11/23/2019
02/04/2019
The post Custom HTML5 Video/Audio And Youtube/Vimeo Players – vLite.js appeared first on CSS Script.
Hot off the heels of Project Hail Mary, Amazon MGM Studios is set to reveal…
PEARL CITY, Ill. (WTVO) — Pearl City, Stephenson County, is recovering from significant damage after…
JOHNSON COUNTY, Ind. (WOWO) — More than 20 people were arrested in Johnson County Wednesday…
Consolidate your car's emergency kit with this combination cordless jump starter, tire inflator, and power…
Between the ubiquitous virtual assistants cheerfully patronising us from almost every electronic device and the…
If you're a Windows user who's looking for a PC version of the Apple Mac…
This website uses cookies.