vue-dplayer 视频播放器

vue-dplayer 是对 dplayer 做的 vue 支持

官网

  1. vue-dplayer
  2. dplayer-doc

示例

  1. 如果默认 options 中没有视频链接,之后设置视频链接时,直接通过 this.options.video.url = videoPath 是无效的
  2. 需要先获取到播放器的实例 this.$refs.player.dp ,然后通过 switchVideo()url 进行修改
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<template>
  <d-player ref="player" :options="options"></d-player>
</template>

<script type="text/ecmascript-6">
  import dPlayer from 'vue-dplayer'
  import 'vue-dplayer/dist/vue-dplayer.css'

  export default {
    name: 'in-video',
    props: {
      source: {
        type: String,
        default: ''
      }
    },
    data () {
      return {
        player: null,
        options: {
          video: {
            url: ''
          },
          contextmenu: [
            {}
          ]
        }
      }
    },
    mounted() {
      this.player = this.$refs.player.dp
    },
	  created() {
      this._setVideoUrl(this.source)
    },
    methods: {
      // 设置视频播放路径
      _setVideoUrl (url) {
        this.player.switchVideo({
          url: url
        })
      }
    },
    components: {
      dPlayer
    }
  }
</script>