第一次用@liveqing/liveplayer,下载依赖,引入并注册组件,但一直报videojs is not
defined,全局搜了,没有videojs,其实vidojs 已经在 livepayer 依赖js中,无需再次引入

下面来正确使用livePlayer

1、先下载依赖

npm install @liveqing/liveplayer

2、在vue.config.js添加配置

const CopyWebpackPlugin = require('copy-webpack-plugin');

module.exports = {
    configureWebpack: {
      plugins: [
        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/'},
        ])
      ]
    }
  }

3、在 public/index.html 中引用 liveplayer-lib.min.js

<head>
        <script src="js/liveplayer-lib.min.js"></script>
</head>

4、引入并使用组件

import LivePlayer from '@liveqing/liveplayer'

  components: {
    LivePlayer
  }

<LivePlayer :videoUrl="videoUrl" fluent autoplay live stretch></LivePlayer>

Logo

前往低代码交流专区

更多推荐