<img height="52px" src="https://github.com/surmon-china/videojs-player/raw/v6.0.0/videojs-logo.png" />
Video.js player component for Vue(3) and React.
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.
If you are looking for a legacy version of the component for Vue2, use the vue-video-player@4.x.
npm install video.js @videojs-player/vue --save
yarn add video.js @videojs-player/vue
import { createApp } from 'vue'
import VueVideoPlayer from '@videojs-player/vue'
import 'video.js/dist/video-js.css'
const app = createApp()
app.use(VueVideoPlayer)
<template>
<video-player
src="https://github.com/surmon-china/videojs-player/raw/v6.0.0/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>
<template>
<video-player :children="[]" ...>
<template v-slot="{ player, state }">
<button @click="state.playing ? player.pause() : player.play()">
{{ state.playing ? 'Pause' : 'Play' }}
</button>
<button @click="player.muted(!state.muted)">
{{ state.muted ? 'UnMute' : 'Mute' }}
</button>
</template>
</video-player>
</template>
npm install video.js @videojs-player/react --save
yarn add video.js @videojs-player/react
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="https://github.com/surmon-china/videojs-player/raw/v6.0.0/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...
/>
)
}
import React from 'react'
import { VideoPlayer } from '@videojs-player/react'
export const Component: React.FC = () => {
return (
<VideoPlayer videoJsChildren={[]} /* props... */>
{({ player, state }) => (
<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 ... */}
)}
</VideoPlayer>
)
}
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 |
$ claude mcp add videojs-player \
-- python -m otcore.mcp_server <graph>