安装 npm install @liveqing/liveplayer
安装 npm install copy-webpack-plugin@4.6.0
在build文件的 webpack.dev.conf.js下插入
const CopyWebpackPlugin = require('copy-webpack-plugin');
......
// copy js lib and swf files to dist dir
new CopyWebpackPlugin([
{ from: 'node_modules/@liveqing/liveplayer/dist/component/crossdomain.xml'},
{ from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer.swf'},
{ from: 'node_modules/@liveqing/liveplayer/dist/component/liveplayer-lib.min.js', to: 'js/'}
]),
......
在vue页面使用
import LivePlayer from '@liveqing/liveplayer'
......
components: {
LivePlayer
}
......
<LivePlayer :videoUrl="videoUrl" fluent autoplay live stretch></LivePlayer>
之前有遇到 **TypeError: The element or ID supplied is not valid. (videojs)**错误
检查 video-url 设置的播放地址 是否有效(可以用 VLC 播放尝试)
提示:Access to XMLHttpRequest at … from origin … has been blocked by CORS policy
检查 video-url 设置的播放地址 是否允许跨域访问
也可以在官方查看 LiveQing