如何在 HTML 页面中播放视频 [英] How to play video in HTML page
问题描述
我正在尝试在我的 HTML 页面上播放 mp4 视频,我搜索了网络并发现在 HTML5 中我可以使用 video
标签来做到这一点,如下所示
I am trying to play a mp4 video on my HTML page, I have searched the web and found that in HTML5 I can do this with video
tag like this below
<video width="320" height="240" autoplay>
<source src="movie.mp4" type="video/mp4">
</video>
我面临的问题
- 我的主要问题是我的视频存储在本地计算机的某个位置,那么我如何从该路径调用它
- 在我的系统中,它位于
D 驱动器
,所以我想从那里调用它 - 我是新手,所以我不知道我的做法是否正确;我的方法正确吗?
- 我的要求是在我的网页上自动播放视频
- My main issue is my video is stored in my local computer in some location, So how can I call that from that path
- In my system it is located in
D drive
so I want to call it from there - I am new to this so I don't know if I am doing it the right way; is my approach correct?
- My requirement is to auto-play video on my web page
我就是这样做的
<video width="320" height="240" autoplay>
<source src="D:\Video\samplevideo.mp4" type="video/mp4">
</video>
D:\Video\samplevideo.mp4
是我的文件路径,samplevideo.mp4
是视频的名称
D:\Video\samplevideo.mp4
is the path of my file and samplevideo.mp4
is the name of the video
在 Chrome 上显示错误 Not allowed to load local resource: file:///D:/Video/samplevideo.mp4
On Chrome it show error Not allowed to load local resource: file:///D:/Video/samplevideo.mp4
在 Firefox 上 所有候选资源都无法加载.媒体加载暂停.
And on Firefox All candidate resources failed to load. Media load paused.
我的主要工作是在网页上播放视频.
My main focus is to play video on webpage.
我需要在页面加载时在网络(HTML 页面)上播放视频我的系统中有该视频位于 D:\Video\samplevideo.mp4
这个路径,我该如何播放加载页面时的视频.
I need to play a video on the web (HTML page) when page is loaded I have that video in my system at D:\Video\samplevideo.mp4
this path, how can I play that video when page is loaded.
推荐答案
试试这个代码
<video muted autoplay loop class="video video js-video" id="hero-vid" poster="video/desktop-screen-banner.png">
<source src="video/movie.webm" type="video/webm">
<source src="video/movie.mp4" type="video/mp4">
<source src="video/movie.ogg" type="video/ogg">
</video>
这篇关于如何在 HTML 页面中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!