下载依赖包
npm install dplayer --save
import引入
import DPlayer from 'dplayer';
使用
dom结构
<template><div class="vedio" id="PlayVideo"></div>
</template>
const initPlayer = () => {// 播放视频state.dp = new DPlayer({// live: true, // 是否为直播container: document.getElementById("PlayVideo"),autoplay: true, //是否自动播放theme: "#0093ff", //主题色loop: true, //视频是否循环播放lang: "zh-cn",playbackSpeed: [1, 2, 4], // 可自定义倍速screenshot: true, //是否开启截图hotkey: true, //是否开启热键preload: "auto", //视频是否预加载volume: 0.7, //默认音量mutex: true, //阻止多个播放器同时播放,当前播放器播放时暂停其他播放器video: {url: state.ruleForm.filepath, //播放视频地址type: "auto",},});
}
注意:还可用于直播,且还有别的属性,可在官网查看了解
官网: link