EasyPlayer.js在使用vue3中使用

npm install @easydarwin/easyplayer --save

把 node_modules/@easydarwin/easyplayer/dist/element目录下的文件

 复制到public内

index.html

<script type="text/javascript" src="/js/EasyPlayer-element.min.js"></script>

在使用的vue内直接写

<template>
<div id="video-player-box">
<easy-player id="EasyPlayer" ref="vVideoPlayerRef" live muted autoplay :has-audio="videoOption.hasAudio" :video-url="videoOption.videoUrl"></easy-player>
<div class="operation-box">
<div>
<el-checkbox v-model="videoOption.hasAudio" label="音频(音频有问题,请设置成false,仅支持flv)" size="large" />
</div>
<div>
<span>视频地址:</span>
<el-input v-model="videoOption.videoUrl" style="width: 500px; margin-right: 10px" placeholder="请输入视频地址" />
<el-button type="primary" @click="initPlay">初始化</el-button>
<el-button v-if="videoOption.status" type="primary" @click="switchVideo">播放</el-button>
<el-button v-else @click="switchVideo">暂停</el-button>
</div>
</div>
</div>
</template>

<script setup>
import { ref } from 'vue';

const videoOption = ref({
//视频地址
videoUrl: '',
//是否静音
hasAudio: false,
status: true
});
const vVideoPlayerRef = ref(null);

const initPlay = () => {
let player = vVideoPlayerRef.value.getVueInstance();
player.destroyPlayer();
player.initPlayer();
};

const switchVideo = () => {
let player = vVideoPlayerRef.value.getVueInstance();
player.switchVideo();
videoOption.value.status = !player.pause;
};
</script>

 

 

配置属性

参数说明类型默认值
alt视频流地址没有指定情况下, 视频所在区域显示的文字String无信号
aspect视频显示区域的宽高比String16:9
autoplay自动播放Booleantrue
currentTime设置当前播放时间Number0
decode-type解码类型 仅支持flv (soft: 强制使用wasm模式)Stringauto
easyStretch是否不同分辨率强制铺满窗口Booleanfalse
live是否直播, 标识要不要显示进度条Booleantrue
loop是否轮播。Booleanfalse
muted是否静音Booleantrue
poster视频封面图片String-
reconnection视频出错时自动重连Booleanfalse
resolution仅支持hls流; 供选择的清晰度 fhd:超清,hd:高清,sd:标清String"yh,fhd,hd,sd"
resolutionDefault仅支持hls流String"hd"
video-url视频地址String-
has-audio是否渲染音频(音频有问题,请设置成false)仅支持flvBooleantrue
video-title视频右上角显示的标题String-
recordMaxFileSize录像文件大小(MB)Number200

事件回调

方法名说明参数
play播放事件 
pause暂时事件 
error播放异常 
ended播放结束或直播断流 
timeupdate当前播放时间回调currentTime

Vue方法

方法名说明参数
initPlayer初始化播放器 
destroyPlayer销毁播放器 
switchVideo播放开关 
switchAudio静音开关 
fullscreen全屏 
exitFullscreen退出全屏 
changeStretch视频拉伸模式 
snapshot保存快照 
switchRecording录像开关

注:has-audio是否渲染音频(音频有问题,请设置成false)仅支持flv

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值