当前位置: 首页 > news >正文

杭州网站设计首选柚米公司代理记账企业

杭州网站设计首选柚米,公司代理记账企业,骑行网站模板,北京影视宣传片拍摄公司说一下easyplayer在vue2中的使用&#xff0c;vue3中没测试&#xff0c;估计应该差不多&#xff0c;大家可自行验证。 安装&#xff1a; pnpm i easydarwin/easyplayer 组件封装 习惯性将其封装为单独的组件 <template><div class"EasyPlayer"><e…

说一下easyplayer在vue2中的使用,vue3中没测试,估计应该差不多,大家可自行验证。

安装:

pnpm i @easydarwin/easyplayer

组件封装

习惯性将其封装为单独的组件

<template><div class="EasyPlayer"><easy-playerstyle="width: 100%;height: 100%;"@error="restartPlayer"@ended="restartPlayer"@play="videoPlay"ref="EasyPlayerRef":videoUrl="url":aspect="aspect":showEnterprise="false":show-custom-button="false":alt="alt":autoplay="autoplay":loop="loop":muted="muted"fluentstretch></easy-player></div>
</template>
<script>import EasyPlayer from '@easydarwin/easyplayer'export default {data() {return {timer: null}},components: { EasyPlayer },props: {url: {type: String,default: ''},aspect: {type: String,default: '16:9'},alt: {type: String,default: '无信号'},autoplay: {type: Boolean,default: true},loop: {type: Boolean,default: true},muted: {type: Boolean,default: true}},destroyed() {if(this.timer) {clearInterval(this.timer)this.timer = null}},methods: {restartPlayer(e) {console.log(e,'播放异常或播放结束或直播断流------->>>>>>>>>')this.$refs.EasyPlayerRef.initPlayer()  //初始化播放器this.$emit('pullFlow')this.timer = setInterval(() => {this.$refs.EasyPlayerRef.initPlayer()  //初始化播放器this.$emit('pullFlow')}, 3000)},// 播放事件videoPlay(a) {// console.log(a,'视频播放------>>')if(this.timer) {clearInterval(this.timer)this.timer = null}},},}
</script>
<style scoped>
.EasyPlayer {width: 100%;height: 100%;
}/* 阻止单击双击视频全屏或者跳转官网 *//* /deep/ .vjs-tech {pointer-events: none!important;} *//* /deep/ .video-js.vjs-fullscreen::backdrop,:not(:root):fullscreen::backdrop {position: fixed!important;top: 0!important;left: 0!important;width: 50%!important;height: 50%!important;right: 50%!important;bottom: 50%!important;background-color: transparent!important;}/deep/ .video-js.vjs-fullscreen .vjs-tech {position: absolute;top: 50%;left: 50%;width: 50%!important;height: 50%!important;transform: translateX(-50%)!important;}/deep/ .video-js {background-color: transparent!important;} */
</style>

 引入使用

<template><div class="container"><div class="easy-player"><EasyPlayer:url="playerUrl"@pullFlow="pullFlow"/></div></div>
</template>
<script>
import EasyPlayer from './EasyPlayer/index.vue'
export default {data() {return {playerUrl: 'http://playertest.longtailvideo.com/adaptive/bipbop/gear4/prog_index.m3u8'}},components: { EasyPlayer },methods:{// 播放异常 重新拉流pullFlow() {// .....}},
}
</script>
<style scoped>
.container {width: 100%;height: 100%;padding: 100px 0 0 100px;box-sizing: border-box;
}.easy-player {width: 450px;height: 300px;border: 1px solid red;
}
</style>

报错处理

会发现控制台有下面报错 

看到报错不要慌,大家跟着我处理

首先我们安装个插件(注意:不要大于6.0版本的,不然会有bug ,还会有乱七八槽的报错): 

pnpm add copy-webpack-plugin@5.1.2 --save-dev

然后在vue.config.js中: 

const { defineConfig } = require("@vue/cli-service");
const CopyWebpackPlugin = require('copy-webpack-plugin')
module.exports = defineConfig({// easy-player  相关configureWebpack: {plugins: [new CopyWebpackPlugin([{from: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer.swf',to: './libs/EasyPlayer/'},{from: 'node_modules/@easydarwin/easyplayer/dist/component/crossdomain.xml',to: './libs/EasyPlayer/'},{from: 'node_modules/@easydarwin/easyplayer/dist/component/EasyPlayer-lib.min.js',to: './libs/EasyPlayer/'}])]},transpileDependencies: true,lintOnSave: false,productionSourceMap: false
});

配置上之后还没完,还需要在public/index.html 引入EasyPlayer-element.min.js,可以直接在node_modules里找到@easydarwin/easyplayer下的dist/element/EasyPlayer-element.min.js复制到pubilc目录下,还有需要EasyPlayer.wasm同样放到public目录下如下所示:

 

然后在public/index.html下再引入即可 

<script src="/lib/EasyPlayer-element.min.js"></script>

这样就OK了!

http://www.yayakq.cn/news/254239/

相关文章:

  • 国外开源建站系统如何查到网站建设
  • 重庆市工程建设信息网官方网站广州外贸网站建设
  • 网站开发对招聘人员要求wordpress 淘宝客 百度
  • 百度建站深圳创业补贴政策2021申请流程
  • 没有网站可以做淘宝客吗微网站是什么时候创建的
  • 学做网站零基础上海自助建网站
  • 定陶住房和城乡建设局网站wordpress怎么修改html代码
  • 如何用ps制作网站连云港市海州区建设局网站
  • 做网站怎么别人搜不出来成都公司的网站制作
  • 仿网站收费苏州网站推
  • 优秀国内个人网站城乡建设网站职业查询系统
  • 网站app免费生成软件网站开发参考书目
  • 餐饮网站网页设计代码个人养老保险怎么买最划算
  • 在网站文字上做笔记哪里有免费的网站域名
  • 沈阳网站设计制作公司张家港阿里网站建设
  • 深圳网站制作建设哪家专业程序小程序开发公司
  • 深圳做律师网站公司友汇网站建设一般多少钱
  • dw中旅游网站怎么做天津专业网站建设
  • 南宁网站建设制作定制wordpress 本地服务器
  • 建设银行的网站特点广州品牌网站设计公司
  • 平面设计软件网站备案用网站建设方案
  • 百度做网站价格110平米三室一厅简装图片
  • 增城做网站要多少钱网站的建设维护推广
  • 阳江建设网站wordpress可以上传网页吗
  • wordpress如何仿站我要下载中国建设网站
  • 网站设计师主要做什么的wordpress版权加密
  • 杭州建设网站网站网站海外seo
  • easyui做网站软件开发是什么意思
  • 大兴建站推广贵阳网站建设黔搜
  • idc销售网站源码公司网站设计模板