<img src="https://raw.githubusercontent.com/bytedance/xgplayer/master/xgplayer.png" width="384" height="96">
<a href="https://www.npmjs.com/package/xgplayer-vue" target="_blank">
<img src="https://img.shields.io/npm/v/xgplayer-vue.svg" alt="npm">
</a>
<a href="https://www.npmjs.com/package/xgplayer-vue" target="_blank">
<img src="https://img.shields.io/npm/l/xgplayer-vue.svg" alt="license">
</a>
<a href="http://commitizen.github.io/cz-cli/">
<img src="https://img.shields.io/badge/commitizen-friendly-brightgreen.svg" alt="commitizen">
</a>
Introduction
xgplayer is a web video player library. It has designed a separate, detachable UI component based on the principle that everything is componentized. More importantly, it is not only flexible in the UI layer, but also bold in its functionality: it gets rid of video loading, buffering, and format support for video dependence. Especially on mp4 it can be staged loading for that does not support streaming mp4. This means seamless switching with clarity, load control, and video savings. It also integrates on-demand and live support for FLV, HLS, and dash. Documentxgplayer-vue is the Vue component which encapsulating the xgplayer.
Start
- Install
```
$ npm install xgplayer-vue@latest
```
- Usage
Step 1. Add xgplayer-vue component
```js
import Xgplayer from 'xgplayer-vue';
export default {
components:{
Xgplayer
}
}
```
Step 2. Use in template
```html
<Xgplayer :config="config" @player="Player = $event"/>
```
Step 3. Config for xgplayer
```js
export default {
data () {
return {
config: {
id: 'vs',
url: '/xgplayer-demo.mp4'
},
Player: null
}
}
}
```
You can use 'config' object to pre-config xgplayer, such as size, volume, autoplay and so on. [More config](http://h5player.bytedance.com/en/config/)
'mp4', 'hls', 'flv', 'dash' are supported to play and you should add the plugin you want to use. [Functional Plugins List](http://h5player.bytedance.com/en/plugins/#functional-plugins-list).
'Player' is the xgplayer instance which exposed from the component. You can use 'Player' to access the API of xgplayer as follows.
API
Attributes
console.log(this.Player.currentTime)
More attributesMethod
this.Player.pause();
More methodsEvent
this.Player.on('play', ()=>{console.log('play')})
More eventsLife Cycle
this.Player.once('ready', ()=>{console.log('ready')})
More eventsPlugins
xgplayer supports your custom plugins for more content viewing pluginsimport Xgplayer from 'xgplayer-vue';
import 'xgplayer-custom';
Demo
$ git clone git@github.com:bytedance/xgplayer-vue.git
$ cd xgplayer-vue
$ npm install
$ npm start
please visit http://localhost:9090/index.html