A Vue 2.x video player component based on DPlayer.
npm install vue-dplayer -S
import VueDPlayer from 'vue-dplayer'
export default {
components: {
'd-player': VueDPlayer
}
}
Name | Type | Default | Description |
---|---|---|---|
autoplay | Boolean | false | autoplay video, not supported by mobile browsers |
theme | String | #FADFA3 | theme color |
loop | Boolean | true | loop play video |
lang | String | zh | zh for Chinese, en for English |
screenshot | Boolean | false | enable screenshot function |
hotkey | Boolean | true | binding hot key, including left right and Space |
preload | String | 'auto' | the way to load video, can be 'none' 'metadata' or 'auto' |
video | Object | required |
video.url -> video link is required, video.pic -> video poster |
Name | Params | Description |
---|---|---|
play | none | Triggered when DPlayer start play |
pause | none | Triggered when DPlayer paused |
canplay | none | Triggered when enough data is available that DPlayer can play |
playing | none | Triggered periodically when DPlayer is playing |
ended | none | Triggered when DPlayer ended playing |
error | none | Triggered when an error occurs |
Example:
<d-player @play="play"></d-player>
export default {
methods: {
play() {
console.log('play callback')
}
}
you can use all DPlayer APIs
Example:
<d-player ref="player"></d-player>
export default {
mounted() {
const player = this.$refs.player.dp
player.play()
setTimeout(() => {
player.pause()
}, 2000)
}
yarn example
: Run example in development modeyarn deploy
: Deploy example to gh-pagesyarn build:cjs
: Build component in commonjs formatyarn build:umd
: Build component in umd formatyarn build
: Build component in both formatyarn lint
: Run eslint
Check out your npm scripts, it's using vbuild under the hood.
Generated by create-vue-app
This content is released under the MIT License.