vue2使用easyplayer

 1.安装easyplayer

npm install @easydarwin/easyplayer --save
npm install [email protected] --save-dev

2.在vue.config.js文件中配置(自测可省略不做配置) 

const CopyWebpackPlugin = require('copy-webpack-plugin')
...
new CopyWebpackPlugin([
  { from: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer.wasm' },
  { from: 'node_modules/@easydarwin/easyplayer/dist/component/crossdomain.xml' },
  { from: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer-lib.min.js', to: 'js/' },
]) 

3.配置静态资源文件

如果是vue-cli3脚手架搭建的vue2项目没有public文件夹 ,复制到static目录下

复制 \node_modules\@easydarwin\easyplayer\dist\component下的

EasyPlayer-lib.min、crossdomain.xml、EasyPlayer.wasm

三个文件到静态资源根目录下(public)

4.在index.html中引入EasyPlayer-lib.min静态资源

...

...

import EasyPlayer from '@easydarwin/easyplayer'

...
components: {
  EasyPlayer
}
...

使用easyplayer还需要导入flv.js,否则文件报错 

npm i flv.js

 easyplayer文档地址:@easydarwin/easyplayer - npm

 easyplayer视频播放测试地址:EasyDarwin 开源流媒体服务器 Open Source Streaming Server

你可能感兴趣的:(vue,javascript,webpack,前端)