# DPlayer-Vue

> A Vue video player component based on [DPlayer](https://github.com/DIYgod/DPlayer).

[![NPM version](https://img.shields.io/npm/v/dplayer-vue.svg?style=flat)](https://npmjs.com/package/dplayer-vue)
[![NPM downloads](https://img.shields.io/npm/dm/vue-dplayer.svg?style=flat)](https://npmjs.com/package/vue-dplayer)

## Install

```bash
npm install dplayer-vue -S
```

## Usage

```js
import VueDPlayer from "dplayer-vue"

export default {
  components: {
    "d-player": VueDPlayer,
  },
}
```

OR

```js
import Vue from "vue"
import VueDPlayer from "dplayer-vue"
Vue.use(VueDPlayer)
```

## Props

[Options Doc](http://dplayer.js.org/#/home?id=options)

| Name    | Type   | Default | Description        |
| ------- | ------ | ------- | ------------------ |
| options | Object | --      | all player options |

Example:

```js
<d-player :options="options"></d-player>

export default {
    data() {
      return {
        options: {
          apiBackend: {
            read: (callback) => {
              callback.error()
              callback.success()
            },
            send: (callback) => {
              callback.error()
              callback.success()
            }
          }
        }
      }
    }
```

## Events

[Event binding Doc](http://dplayer.js.org/#/home?id=event-binding)

Example:

```js
<d-player @play="play"></d-player>

export default {
    methods: {
      play() {
        console.log('play callback')
      }
    }
```

## API

you can use all DPlayer [APIs](http://dplayer.js.org/#/home?id=api)

Example:

```js
<d-player ref="player"></d-player>

export default {
    mounted() {
      const player = this.$refs.player.dp
      player.play()
      setTimeout(() => {
        player.pause()
      }, 2000)
    }
```

## Related

- [DPlayer](https://github.com/DIYgod/DPlayer)

# License

This content is released under the [MIT](http://opensource.org/licenses/MIT) License.
