问题
I am using video tag html But video is not playing when page is loaded then after move another page is working.please give me solution.
<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>
Return Error:: Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first.
回答1:
You can add controls
attribute in video tag and remove 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>
来源:https://stackoverflow.com/questions/50982396/video-is-not-playing-in-angular-4-but-refresh-page-is-working