Vue video player Vue video plug in

Keywords: Vue html5 Mobile npm


vue video player is the vue version of videojs
video.js Official website:
Refer to the official website: Video.js Is a web video player built from scratch for the HTML5 world. It supports HTML5 video and modern streaming formats, and it supports video playback on desktops and mobile devices.


  1. Installation depends on NPM I Vue video player-d
  2. Global reference:
	// stay mian.js Introduced inside
	import "video.js/dist/video-js.css";
	import {videoPlayer} from "vue-video-player";

Or local reference

	// Page index in use
	import "video.js/dist/video-js.css";
    import {videoPlayer} from "vue-video-player";
    // Declare video player in components
    components: {


<video-player class="video-player vjs-custom-skin"

Configuration item


  • Playbackrates: [0.5, 1.0, 1.5, 2.0], / / optional playback speed
  • Autoplay: false, / / if true, the browser will play back when it is ready.
  • Muted: false, / / any audio will be removed by default.
  • Loop: false, / / start again as soon as the video ends.
  • preload: 'auto', / / it is recommended that the browser start downloading video data after loading elements. Auto browser selects the best behavior and starts loading the video immediately (if supported by the browser)
  • language : 'zh-CN',
  • aspectRatio: '16:9', / / places the player in fluent mode and uses this value when calculating the dynamic size of the player. The value should represent a scale - two numbers separated by colons (for example, "16:9" or "4:3")
  • Fluid: true, / / when true, Video.js The player will have the fluid size. In other words, it scales to fit its container.
  • sources : [{ type : “”, src : ‘ ’//url address}],
  • Post: "", / / your cover address
  • width: document.documentElement.clientWidth,
  • notSupportedMessage: 'this video cannot be played temporarily. Please try again later', / / overwrite allowed Video.js Default information displayed when the media source cannot be played.
  • ControlBar: {timedivider: true, / / the separator of current time and duration durationdisplay: true, / / display durationtimedisplay: false, / / display the remaining time function fullscreentoggle: true / / full screen button


methods: {
    //Monitor and play
    onPlayerPlay (player) {
        // this.$;
    //Monitor pause
    onPlayerPause (player) {
        // this.$refs.videoPlayer.player.pause();
    //Monitor and play status change
    playerStateChanged (player) {
        // console.log(player);
    //Monitor whether the media has reached the end and played out
    onPlayerEnded (player) {
        // console.log(player);
    //A readyState change on the DOM element causes playback to stop.
    onPlayerWaiting (player) {
        // console.log(player);
    //The media is no longer banned and has started playing.
    onPlayerPlaying (player) {
        // console.log(player);
    //Triggered when the player downloads data at the current playing position
    onPlayerLoadeddata (player) {
        // console.log(player);
    //Triggered when the current playback position changes.
    onPlayerTimeupdate (player) {
        // console.log(player);
    //The readyState of the media is HAVE_FUTURE_DATA or higher
    onPlayerCanplay(player) {
        // console.log('player Canplay!', player)
    //The readyState of the media is HAVE_ENOUGH_DATA or higher. This means that the entire media file can be played without buffering.
    onPlayerCanplaythrough(player) {
        // console.log('player Canplaythrough!', player)
    //Bind the listener to the ready state of the component. The difference from the event listener is that if the ready event has already occurred, it will trigger the function immediately..
    playerReadied(player) {
        // seek to 10s
        console.log('example player 1 readied', player);
        // player.currentTime(0)
        // console.log('example 01: the player is readied', player)

Posted by chiprivers on Thu, 11 Jun 2020 21:27:52 -0700