本文介绍了如果不进行硬刷新,视频自动播放将无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有视频背景.它使用自动播放.在这里:
I have a video background. It uses autoplay. Here it is:
<video muted loop autoPlay >
<source src="assets/videos/background.mp4" type="video/mp4">
</video>
仅在以下页面上有效:1.硬刷新(正常负载不起作用)2.导航到(如果我在另一个页面上,然后导航到主页)
This works ONLY if the page is: 1. Hard refreshed (normal load does not work) 2. Navigated to (If I am on another page and then navigate to the home page)
如果仅浏览至链接,则该链接无效.链接: https://jackseabolt.github.io/trasher/(请不要与网站)
If you simply navigate to the link, it doesn't work. Link: https://jackseabolt.github.io/trasher/ (please don't mess with the site)
对这里发生的事情有任何想法吗?
Any thoughts about what's going on here?
推荐答案
您并不是说在项目中使用Angular.现在很简单:
You didn't say that using an Angular in your project. That's simple now:
<video [muted]="true" autoplay playsinline loop>
<source src="your_video" type="video/mp4">
</video>
只需将 muted
属性更改为 [muted] ="true"
.
这篇关于如果不进行硬刷新,视频自动播放将无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!