SoFunction
Updated on 2025-04-04

Detailed explanation of the usage configuration of vue-video-player video player

This article shares the usage configuration of vue-video-player video player for your reference. The specific content is as follows

1. Installation

npm install vue-video-player -save

2. Add in

import VueVideoPlayer from 'vue-video-player' // Video playerimport '/dist/'

(VueVideoPlayer)

3. Create a new component for call

<template>
 <div >
 <video-player class="video-player vjs-custom-skin" ref="videoPlayer" :playsinline="true" :options="playerOptions"></video-player>
 </div>
</template>

<script>
export default {
 name: 'vueVideoPlayer',
 props: {
 src: {
  type: String
 },
 cover_url: {
  type: String
 }
 },
 data () {
 return {
 // Configuration information  playerOptions: {
  playbackRates: [0.7, 1.0, 1.5, 2.0], // Playback speed  autoplay: false, // If true, playback begins when the browser is ready.  muted: false, // By default, any audio will be eliminated.  loop: false, // causes the video to start again as soon as it ends.  preload: 'auto', // It is recommended that the browser start downloading video data after the <video> loads the element.  Auto browser selects the best behavior and start loading videos immediately (if the browser supports it)  language: 'zh-CN',
  aspectRatio: '16:10', // Put the player in smooth mode and use this value when calculating the dynamic size of the player.  The value should represent a proportion - two numbers separated by colons (e.g. "16:9" or "4:3")  fluid: true, // When true, the player will have the fluid size.  In other words, it will scale to fit its container.  sources: [{
   src: , // Path   type: 'video/mp4' // type  }],
  poster: this.cover_url, // Your cover address  // width: ,
  notSupportedMessage: 'This video cannot be played for the time being, please try again later', // Allows to overwrite the default information displayed when the media source cannot be played.  controlBar: {
   timeDivider: true,
   durationDisplay: true,
   remainingTimeDisplay: false,
   fullscreenToggle: true // Full screen button  }
  }
 }
 }
}

4. Calling in other components

&lt;vueVideoPlayer :src="" :cover_url="data.cover_url" /&gt;

import vueVideoPlayer from './module/vueVideoPlayer'
// Don't forget to registercomponents: {
 vueVideoPlayer 
}

Regarding the tutorial on components, please click on the topicComponent learning tutorialCarry out learning.

For more vue learning tutorials, please read the topic"Vue Practical Tutorial"

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.