Top Related Projects
Video.js - open source HTML5 video player
A simple HTML5, YouTube and Vimeo player
:clapper: An extensible media player for the web.
JW Player is the world's most popular embeddable media player.
The HTML5 video player for the web
Quick Overview
VideoJS Player is a customizable and feature-rich wrapper for the popular Video.js library. It provides additional functionality and an enhanced user interface for video playback, making it easier to integrate and customize video players in web applications.
Pros
- Enhanced UI with additional controls and features
- Easy integration with existing Video.js projects
- Customizable themes and appearance
- Supports multiple video sources and formats
Cons
- Dependency on Video.js library
- May have a steeper learning curve for beginners
- Limited documentation compared to the core Video.js library
- Potential performance overhead due to additional features
Code Examples
- Basic player initialization:
import VideoPlayer from 'videojs-player';
const player = new VideoPlayer({
el: '#video-container',
source: 'https://example.com/video.mp4',
poster: 'https://example.com/poster.jpg',
autoplay: true
});
- Adding custom controls:
const player = new VideoPlayer({
el: '#video-container',
source: 'https://example.com/video.mp4',
controls: {
playToggle: true,
volumePanel: true,
customButtons: [
{
text: 'Custom Button',
clickHandler: () => {
console.log('Custom button clicked');
}
}
]
}
});
- Handling events:
const player = new VideoPlayer({
el: '#video-container',
source: 'https://example.com/video.mp4'
});
player.on('play', () => {
console.log('Video started playing');
});
player.on('ended', () => {
console.log('Video playback finished');
});
Getting Started
- Install the package:
npm install videojs-player
- Import and use in your project:
import VideoPlayer from 'videojs-player';
const player = new VideoPlayer({
el: '#video-container',
source: 'https://example.com/video.mp4',
width: 640,
height: 360,
controls: true,
autoplay: false
});
// Access Video.js methods
player.play();
player.pause();
player.currentTime(30);
Make sure to include the necessary CSS file for styling:
<link rel="stylesheet" href="path/to/videojs-player.css">
Competitor Comparisons
Video.js - open source HTML5 video player
Pros of video.js
- Larger community and more extensive documentation
- More comprehensive feature set and plugin ecosystem
- Regular updates and maintenance from a dedicated team
Cons of video.js
- Steeper learning curve for beginners
- Larger file size and potentially heavier resource usage
- May require more configuration for specific use cases
Code Comparison
videojs-player:
import Player from 'videojs-player'
const player = new Player({
el: '#video-player',
source: 'path/to/video.mp4',
autoplay: true
})
video.js:
import videojs from 'video.js'
const player = videojs('video-player', {
sources: [{ src: 'path/to/video.mp4', type: 'video/mp4' }],
autoplay: true
})
Key Differences
- videojs-player is a wrapper around video.js, providing a simpler API for basic use cases
- video.js offers more granular control and customization options
- videojs-player has a smaller footprint but fewer features out of the box
Use Cases
- Choose videojs-player for quick implementation and simpler projects
- Opt for video.js when advanced features and extensive customization are required
Community and Support
- video.js has a larger user base and more active community support
- videojs-player benefits from video.js updates but may have slower adoption of new features
A simple HTML5, YouTube and Vimeo player
Pros of Plyr
- Lightweight and more customizable UI
- Better support for modern web technologies (e.g., custom properties, SVG icons)
- Easier to set up and use out of the box
Cons of Plyr
- Less extensive plugin ecosystem compared to Video.js
- May require more manual configuration for advanced features
- Smaller community and fewer third-party resources
Code Comparison
Plyr initialization:
const player = new Plyr('#player', {
controls: ['play-large', 'play', 'progress', 'current-time', 'mute', 'volume', 'captions', 'settings', 'pip', 'airplay', 'fullscreen'],
});
Videojs-player initialization:
const player = videojs('player', {
controls: true,
autoplay: false,
preload: 'auto',
fluid: true,
});
Both libraries offer simple initialization, but Plyr provides more granular control over which UI elements to display by default. Videojs-player relies more on plugins and additional configuration for customization.
Plyr focuses on a modern, minimalist approach with a sleek UI and easy customization. It's ideal for projects that prioritize simplicity and a contemporary look. Videojs-player, built on Video.js, offers a more extensive feature set and plugin ecosystem, making it suitable for complex video implementations with specific requirements.
:clapper: An extensible media player for the web.
Pros of Clappr
- More lightweight and modular architecture
- Better support for live streaming
- Extensive plugin ecosystem for customization
Cons of Clappr
- Smaller community and less frequent updates
- Limited built-in features compared to VideoJS Player
- Steeper learning curve for advanced customizations
Code Comparison
VideoJS Player:
import videojs from 'video.js';
const player = videojs('my-video', {
controls: true,
autoplay: false,
preload: 'auto'
});
Clappr:
import Clappr from 'clappr';
const player = new Clappr.Player({
source: 'video.mp4',
parentId: '#player',
autoPlay: false
});
Both libraries offer simple setup, but Clappr's initialization is more concise. VideoJS Player provides more configuration options out of the box, while Clappr relies on plugins for advanced features.
VideoJS Player is based on the widely-used Video.js library, offering extensive documentation and community support. It's ideal for projects requiring a robust, feature-rich player with broad browser compatibility.
Clappr, on the other hand, excels in scenarios where a lightweight, customizable player is needed, especially for live streaming applications. Its modular architecture allows for easy extension through plugins, but may require more effort for complex setups.
JW Player is the world's most popular embeddable media player.
Pros of jwplayer
- More comprehensive and feature-rich player with advanced customization options
- Robust documentation and extensive API for developers
- Wider range of supported formats and streaming protocols
Cons of jwplayer
- Commercial product with licensing fees, unlike the open-source videojs-player
- Steeper learning curve due to its complexity and extensive features
- Larger file size and potentially higher resource usage
Code Comparison
videojs-player:
import videojs from 'video.js';
const player = videojs('my-video', {
controls: true,
autoplay: false,
preload: 'auto'
});
jwplayer:
jwplayer("my-player").setup({
file: "video.mp4",
width: "100%",
aspectratio: "16:9",
autostart: false
});
Both players offer simple setup options, but jwplayer provides more advanced configuration possibilities out of the box. videojs-player relies more on plugins for extended functionality, while jwplayer includes many features natively.
The videojs-player is based on the popular video.js library, making it lightweight and easy to integrate into existing projects. It's ideal for developers who need a basic video player with the flexibility to add custom features through plugins.
jwplayer, on the other hand, is a more comprehensive solution that comes with built-in analytics, advertising support, and advanced streaming capabilities. It's better suited for enterprise-level applications or projects requiring a full-featured video platform.
The HTML5 video player for the web
Pros of Flowplayer
- More mature and established project with a longer history
- Extensive documentation and API reference
- Commercial support and enterprise options available
Cons of Flowplayer
- Larger file size and potentially heavier resource usage
- Less frequent updates and releases compared to videojs-player
Code Comparison
videojs-player:
import VideoPlayer from 'videojs-player'
const player = new VideoPlayer({
el: '#video-container',
source: 'path/to/video.mp4',
autoplay: true
})
Flowplayer:
flowplayer('#player', {
clip: {
sources: [
{ type: 'video/mp4', src: 'path/to/video.mp4' }
]
},
autoplay: true
})
Both libraries offer similar functionality for creating video players, but with slightly different syntax and configuration options. Flowplayer uses a more traditional approach with a global function, while videojs-player employs a more modern, modular import system.
videojs-player is a newer project that builds upon the popular Video.js library, offering a streamlined and customizable player solution. It may be more suitable for developers looking for a lightweight and flexible option.
Flowplayer, on the other hand, has a longer track record and may be preferred by enterprises or projects requiring extensive documentation and commercial support. However, its larger file size and less frequent updates might be drawbacks for some users.
Ultimately, the choice between these two libraries depends on specific project requirements, desired features, and the level of support needed.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
videojs-player
Video.js player component for Vue(3) and React.
BREAKING CHANGE â ï¸
The vue-video-player
package has now been renamed to @videojs-player/vue
due to the addition of support for React. Also, support for Vue has undergone a Breaking change, with the latest version of the component only supporting Vue3.
The last version of the vue-video-player
package will be released in v6.0, which will just re-export everything from @videojs-player/vue
, so if you're ready to use the new version of vue-video-player
, please import @videojs-player/vue
directly.
The latest version of videojs-player supports responsiveness for the vast majority of Video.js configuration options and allows you to fully customize the player's control panel and interaction details, thanks to the fact that the component does enough processing internally for different frameworks.
Legacy Version
If you are looking for a legacy version of the component for Vue2, use the vue-video-player@5.x
Component Documentation
Video.js Documentation
Usage (Vue)
Install
npm install video.js @videojs-player/vue --save
yarn add video.js @videojs-player/vue
Global component
import { createApp } from 'vue'
import VueVideoPlayer from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
const app = createApp()
app.use(VueVideoPlayer)
Local component
<template>
<video-player
src="/your-path/video.mp4"
poster="/your-path/poster.jpg"
controls
:loop="true"
:volume="0.6"
...
@mounted="..."
@ready="..."
@play="..."
@pause="..."
@ended="..."
@seeking="..."
...
/>
</template>
<script>
import { defineComponent } from 'vue'
import { VideoPlayer } from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
export default defineComponent({
components: {
VideoPlayer
}
})
</script>
Custom player controls
<template>
<video-player :children="[]" ...>
<template v-slot="{ player, state }">
<div class="custom-player-controls">
<button @click="state.playing ? player.pause() : player.play()">
{{ state.playing ? 'Pause' : 'Play' }}
</button>
<button @click="player.muted(!state.muted)">
{{ state.muted ? 'UnMute' : 'Mute' }}
</button>
<!-- more custom controls elements ... -->
</div>
</template>
</video-player>
</template>
Usage (React)
Install
npm install video.js @videojs-player/react --save
yarn add video.js @videojs-player/react
Component
import React from 'react'
import { VideoPlayer } from '@videojs-player/react'
import 'video.js/dist/video-js.css'
export const Component: React.FC = () => {
return (
<VideoPlayer
src="/your-path/video.mp4"
poster="/your-path/poster.jpg"
controls
loop={true}
volume={0.6}
// more props...
onMounted={/*...*/}
onReady={/*...*/}
onPlay={/*...*/}
onPause={/*...*/}
onEnded={/*...*/}
onSeeking={/*...*/}
// more events...
/>
)
}
Custom player controls
import React from 'react'
import { VideoPlayer } from '@videojs-player/react'
export const Component: React.FC = () => {
return (
<VideoPlayer videoJsChildren={[]} /* props... */>
{({ player, state }) => (
<div class="custom-player-controls">
<button onClick={() => state.playing ? player.pause() : player.play()}>
{{ state.playing ? 'Pause' : 'Play' }}
</button>
<button onClick={() => player.muted(!state.muted)}>
{{ state.muted ? 'UnMute' : 'Mute' }}
</button>
{/* more custom controls elements ... */}
</div>
)}
</VideoPlayer>
)
}
Component Props
All parameters are optional and Video.js determines the default value of each prop.
"responsive"
means that if the prop value you pass in the component changes,
Video.js will automatically respond to the corresponding update,
e.g. a change in volume
will cause the player to change the volume.
Prop Name | Video.js API Doc & Description | Type | Responsive |
---|---|---|---|
id | options.id | String | |
src | options.src | String | â |
sources | options.sources | Array | â |
width | options.width | Number | â |
height | options.height | Number | â |
preload | options.preload | String | â |
loop | options.loop | Boolean | â |
muted | options.muted | Boolean | â |
poster | options.poster | String | â |
controls | options.controls | Boolean | â |
autoplay | options.autoplay | Boolean | String | â |
playsinline | options.playsinline | Boolean | â |
crossorigin | options.crossOrigin | String | â |
volume | A number, between 0 and 1, control the volume of the player. | Number | â |
playbackRate | Control the playback rate of the player. | Number | â |
playbackRates | options.playbackRates | Array<Number> | â |
fluid | options.fluid | Boolean | â |
fill | options.fill | Boolean | â |
language | options.language | String | â |
languages | options.languages | Object | |
tracks | options.tracks | Array | â |
textTrackSettings | options.textTrackSettings | Object | â |
responsive | options.responsive | Boolean | â |
breakpoints | options.breakpoints | Object | â |
fullscreen | options.fullscreen | FullscreenOptions | |
aspectRatio | options.aspectRatio | Boolean | â |
liveui | options.liveui | Boolean | |
liveTracker | options.liveTracker | Object | |
disablePictureInPicture | options.disablePictureInPicture | Boolean | â |
notSupportedMessage | options.notSupportedMessage | String | â |
normalizeAutoplay | options.normalizeAutoplay | Boolean | â |
audioPosterMode | options.audioPosterMode | Boolean | â |
audioOnlyMode | options.audioOnlyMode | Boolean | â |
noUITitleAttributes | options.noUITitleAttributes | Boolean | |
preferFullWindow | options.preferFullWindow | Boolean | |
suppressNotSupportedError | options.suppressNotSupportedError | Boolean | |
techCanOverridePoster | options.techCanOverridePoster | Boolean | |
techOrder | options.techOrder | Array | |
inactivityTimeout | options.inactivityTimeout | Number | |
userActions | options.userActions | Object | |
restoreEl | options.restoreEl | Boolean | Element | |
vtt.js | options['vtt.js'] | String | |
children (Vue) videoJsChildren (React) | options.children | Array | Object | |
html5 | options.html5 | Object | |
plugins | options.plugins | Object | |
options | A fallback scheme, if you need to use options that don't exist in props, pass them to options . | VideoJsPlayerOptions |
Component Events
Events emitted by Video.js, the argument type is always EventTarget
.
Video.js Event | ð«¥ ð«¥ ð«¥ ð«¥ ð«¥ ð«¥ | Vue | React |
---|---|---|---|
event.loadstart | - | @loadstart | onLoadStart |
event.suspend | - | @suspend | onSuspend |
event.abort | - | @abort | onAbort |
event.error | - | @error | onError |
event.emptied | - | @emptied | onEmptied |
event.stalled | - | @stalled | onStalled |
event.loadedmetadata | - | @loadedmetadata | onLoadedMetadata |
event.loadeddata | - | @loadeddata | onLoadedData |
event.canplay | - | @canplay | onCanPlay |
event.canplaythrough | - | @canplaythrough | onCanPlayThrough |
event.playing | - | @playing | onPlaying |
event.waiting | - | @waiting | onWaiting |
event.seeking | - | @seeking | onSeeking |
event.seeked | - | @seeked | onSeeked |
event.ended | - | @ended | onEnded |
event.durationchange | - | @durationchange | onDurationChange |
event.timeupdate | - | @timeupdate | onTimeUpdate |
event.progress | - | @progress | onProgress |
event.play | - | @play | onPlay |
event.pause | - | @pause | onpause |
event.ratechange | - | @ratechange | onRateChange |
event.resize | - | @resize | onResize |
event.volumechange | - | @volumechange | onVolumeChange |
event.posterchange | - | @posterchange | onPosterChange |
event.languagechange | - | @languagechange | onLanguageChange |
event.fullscreenchange | - | @fullscreenchange | onFullscreenChange |
event.playbackrateschange | - | @playbackrateschange | onPlaybackRatesChange |
event.controlsdisabled | - | @controlsdisabled | onControlsDisabled |
event.controlsenabled | - | @controlsenabled | onControlsEnabled |
event.enterFullWindow | - | @enterFullWindow | onEnterFullWindow |
event.exitFullWindow | - | @exitFullWindow | onExitFullWindow |
event.enterpictureinpicture | - | @enterpictureinpicture | onEnterPictureInPicture |
event.leavepictureinpicture | - | @leavepictureinpicture | onLeavePictureInPicture |
event.sourceset | - | @sourceset | onSourceSet |
event.texttrackchange | - | @texttrackchange | onTextTrackChange |
event.textdata | - | @textdata | onTextData |
event.useractive | - | @useractive | onUserActive |
event.userinactive | - | @userinactive | onUserInactive |
event.usingcustomcontrols | - | @usingcustomcontrols | onUsingCustomControls |
event.usingnativecontrols | - | @usingnativecontrols | onUsingNativeControls |
event.dispose | - | @dispose | onDispose |
event.beforepluginsetup | - | @beforepluginsetup | onBeforePluginSetup |
event.pluginsetup | - | @pluginsetup | onPluginSetup |
event.componentresize | - | @componentresize | onComponentResize |
event.playerresize | - | @playerresize | onPlayerResize |
event.tap | - | @tap | onTap |
event.ready | - | @ready | onReady |
The events emitted by videojs-player component.
Component Event | Description | Vue | React |
---|---|---|---|
mounted | Fires when player component mounted. ({ video: HTMLVideoElement, player: VideoJsPlayer, state: VideoPlayerState }) | @mounted | onMounted |
unmounted | Fires when player component unmounted. | @unmounted | onUnmounted |
stateChange | Fires when player state changed (React only). (state: VideoPlayerState) | - | onStateChange |
Player State
The component maintains a fully responsive state object internally with the player so that you can consume the player state out-of-the-box outside the player,
you can get this object via the mounted
event or stateChange
(React Only).
Key | Description | Value type |
---|---|---|
src | The URL of the currently playing video. | String |
currentSrc | ditto | String |
currentSource | The currently playing video source object. | videojs.Tech.SourceObject |
width | Player's width. | Number |
height | Player's height. | Number |
currentWidth | ditto | Number |
currentHeight | ditto | Number |
videoWidth | Video element's width. | Number |
videoHeight | Video element's height. | Number |
controls | Whether player controls are enabled or not. | Boolean |
volume | Player's volume. | Number |
muted | Is the player muted. | Boolean |
poster | Player poster image URL. | String |
playing | Is it playing now. | Boolean |
waiting | Is it waiting now. | Boolean |
seeking | A seek operation began. | Boolean |
paused | Playback has been paused. | Boolean |
ended | Playback has stopped because the end of the media was reached. | Boolean |
currentTime | - | Number |
duration | - | Number |
playbackRate | - | Number |
playbackRates | - | Array<Number> |
isFullscreen | - | Boolean |
isInPictureInPicture | Whether it is picture-in-picture mode. | Boolean |
isLive | Is the currently playing live video. | Boolean |
language | Video.js current language. | String |
userActive | - | Boolean |
readyState | - | videojs.ReadyState |
networkState | - | videojs.NetworkState |
error | A Custom MediaError of Video.js. | MediaError | Null |
buffered | An object that contains ranges of time. | videojs.TimeRange |
bufferedPercent | - | Number |
played | - | TimeRanges |
seekable | - | TimeRanges |
textTracks | - | videojs.TextTrackList |
audioTracks | - | videojs.AudioTrackList |
videoTracks | - | videojs.VidioTrackList |
Video.js extension
import videojs from 'video.js'
// Video.js plugin
const Plugin = videojs.getPlugin('plugin')
class ExamplePlugin extends Plugin {
// do something...
}
videojs.registerPlugin('examplePlugin', ExamplePlugin)
// more Video.js operation...
Development
pnpm install
pnpm dev
pnpm dev:vue
pnpm dev:react
pnpm build
pnpm build:vue
pnpm build:react
pnpm lint
pnpm test
pnpm rebirth
pnpm release
Changelog
License
Licensed under the MIT License.
Top Related Projects
Video.js - open source HTML5 video player
A simple HTML5, YouTube and Vimeo player
:clapper: An extensible media player for the web.
JW Player is the world's most popular embeddable media player.
The HTML5 video player for the web
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot