1.vue中的html引入ezuikit
<script type="text/javascript" src="./ezuikit.js"></script>
2.使用
<video
id="myPlayers"
autoplay
controls
style="width:100%;height:100%; object-fit: fill"
></video>
videoOpen() {
const that = this;
setTimeout(() => {
try {
if (!that.previewUrl) {
throw new Error("视频预览 URL 不存在或未定义。");
}
const ezopenUrl =
"ezopen://" + that.previewUrl.replace(/\.m3u8$/, "");
const playerElement = document.getElementById("myPlayers");
if (!playerElement) {
throw new Error("无法找到与 ID 'myPlayer' 相对应的元素。");
}
that.player = new EZUIKit.HLS("myPlayers", that.previewUrl);
} catch (error) {
console.error("初始化 EZUIKitPlayer 时出错:", error);
}
}, 200);
},
handleClose() {
if (this.player) {
this.player.stop();
}
this.previewUrl=null;
},