我正在使用视频标签html 但是加载页面后无法播放视频,然后移动另一个页面后即可。请给我解决方法。
<video #videoPlayer class="slider-video" width="100%" preload="auto" loop="" muted="muted" style="visibility: visible; width: 100%;"
poster="assets/images/banner.png" src="https://wellfasterstore.blob.core.windows.net/images/1.mp4" type="video/mp4" autoplay="autoplay">
</video>
返回错误:: 未捕获(承诺)的DOMException:play()失败,因为用户没有首先与文档进行交互。
答案 0 :(得分:0)
您可以在视频代码中添加controls
属性,然后删除autoplay="autoplay"
<video
controls
#videoPlayer
class="slider-video"
width="100%"
preload="auto"
loop=""
muted="muted"
style="visibility: visible; width: 100%;"
poster="assets/images/banner.png"
src="https://wellfasterstore.blob.core.windows.net/images/1.mp4"
type="video/mp4">
</video>