我想在这段代码中 实现video全屏后铺满屏幕: let options = { controls: true, // 是否显示底部控制栏 preload: "auto", // 加载<video>标签后是否加载视频 autoplay: "muted", // 静音播放 height: "170px", width: "270px", }; CameraDao.getCameraUrl({"syncId": dev.syncId}).then(res => { let url = res.data.url if (res.data.msg == "网络连接失败") { that.$message.error("接口请求失败,请稍后重试"); } else { setTimeout(() => { Array.from( document.getElementsByClassName("vjs-loading-spinner") ).forEach((it) => { it && it.setAttribute("style", "display: none;"); }); that.player = that.$video("videoPlayer", options); if (dev.status === "正常") { that.player.src(url); that.player.load(url); that.player.play(); } }, 500); } })
时间: 2024-02-10 21:13:17 浏览: 20
你可以在初始化 Video.js 播放器时,设置视频的宽高比为屏幕的宽高比,这样视频就可以铺满全屏了。具体实现可以参考以下代码:
```
let options = {
controls: true,
preload: "auto",
autoplay: "muted",
height: "170px",
width: "270px",
aspectRatio: "16:9" // 设置宽高比为16:9
};
CameraDao.getCameraUrl({"syncId": dev.syncId}).then(res => {
let url = res.data.url
if (res.data.msg == "网络连接失败") {
that.$message.error("接口请求失败,请稍后重试");
} else {
setTimeout(() => {
Array.from(document.getElementsByClassName("vjs-loading-spinner")).forEach((it) => {
it && it.setAttribute("style", "display: none;");
});
that.player = that.$video("videoPlayer", options);
if (dev.status === "正常") {
that.player.src(url);
that.player.load(url);
that.player.play();
}
}, 500);
}
});
```
这里的 `aspectRatio` 属性设置为 `16:9`,表示视频的宽高比为 16:9,可以根据实际情况进行调整。这样视频在全屏模式下就会按照比例铺满屏幕了。