SoFunction
Updated on 2025-04-05

vue-dplayer video player instance code

Official website

vue-dplayer

dplayer-doc

Example

If there is no video link in the default options, when setting the video link later, it is invalid to pass = videoPath directly

You need to get the player instance this.$ first, and then modify the url through switchVideo()

<template>
 <d-player ref="player" :options="options"></d-player>
</template>

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

 export default {
 name: 'in-video',
 props: {
  source: {
  type: String,
  default: ''
  }
 },
 data () {
  return {
  player: null,
  options: {
   video: {
   url: ''
   },
   contextmenu: [
   {}
   ]
  }
  }
 },
 mounted() {
   = this.$
 },
 created() {
  this._setVideoUrl()
 },
 methods: {
  // Set the video playback path  _setVideoUrl (url) {
  ({
   url: url
  })
  }
 },
 components: {
  dPlayer
 }
 }
</script>