liveplayer和easyplayer使用方法很相似,属性也基本相同,下面开始liveplayer使用方法:
1.npm安装liveplayer、copy-webpack-plugin
npm install @liveqing/liveplayer
npm install copy-webpack-plugin@4.0.1 --save-dev
也可在package.json文件中直接添加版本号,然后执行yarn install 或 npm install:
"dependencies": {
"@liveqing/liveplayer": "2.3.3",
},
"devDependencies": {
"copy-webpack-plugin": "^4.0.1",
}
2.在vue.config.js文件中配置
const CopyWebpackPlugin = require('copy-webpack-plugin')
...
new CopyWebpackPlugin([
{ from: 'node_modules/@liveqing/liveplayer/dist/component/crossdomain.xml' },
{ from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer-lib.min.js', to: 'js/' },
{ from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer.swf' },
{ from: 'node_modules/@liveqing/liveplayer/dist/element/liveplayer-element.min.js', to: 'js/' },
])
3.在public/index.html中引入js静态资源
注意:文件位置要与上面配置的to...相同,上面配置是的 to: 'js/',所以底下地址是./js
<!--引入liveplayer依赖-->
<script src="./js/liveplayer-lib.min.js"></script>
<script src="./js/liveplayer-element.min.js"></script>
或
<script src="<%= BASE_URL %>js/liveplayer-lib.min.js"></script>
<script src="<%= BASE_URL %>js/liveplayer-element.min.js"></script>
4.在vue中使用
<live-player
:video-url="item.videoUrl"
:poster="item.poster"
:live="true"
:stretch="true"
:controls="item.carouselShow ? false : true"
:hide-big-play-button="true"
alt=""
></live-player>
...
import LivePlayer from '@liveqing/liveplayer'
...
components: { LivePlayer }
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。