1.安装依赖
npm install vue-video-player videojs-contrib-hls --save
2.创建videoplayer插件
import Vue from 'vue'
const VueVideoPlayer = require('vue-video-player/dist/ssr')
const hls = require('videojs-contrib-hls')
Vue.use(hls)
Vue.use(VueVideoPlayer)
3.配置nuxt.config.js
plugins: [ '@/plugins/videoplayer' ]
4.使用
<template>
<section>
<div
v-video-player:myVideoPlayer="playerOptions"
:playsinline="playsinline"
class="video-player-box vjs-big-play-centered"
@play="onPlayerPlay($event)"
@pause="onPlayerPause($event)"
@ended="onPlayerEnded($event)"
@loadeddata="onPlayerLoadeddata($event)"
@waiting="onPlayerWaiting($event)"
@playing="onPlayerPlayi