2017-04-12 74 views
0

当使用相对位置的相当简单的将在网站上的视频:HTML5视频源标记语法

<source src="videos/video.mp4" type="video/mp4"/> 

不过,我需要从一个完全不同的目录中插入视频文件。 像 “C:\一些\文件夹\ onthedrive \视频”

但该项目是在: “C:\ XAMPP \ htdocs中\项目名称”

我也曾尝试这些东西:

<source src="file://C:\Some\Folder\onthedrive\videos\video.mp4" type="video/mp4"/> 
<source src="file://C:/Some/Folder/onthedrive/videos/video.mp4" type="video/mp4"/> 

我能做些什么来解决这个问题?

编辑

<source src="file://C:\Some\Folder\onthedrive\videos\video.mp4" type="video/mp4"/> 

实际工作中,网络服务器和浏览器的认可,但由于安全其中的一个决定不加载该文件。

Chrome:'不允许加载本地资源'。

回答

3

您必须将“file://”更改为“file:///”。

为什么使用三条斜杠? “文件:/// C:/等” 是一个快捷方式 “文件://本地主机/ C:/等”

,你可以在这里找到:file URI scheme

编辑:

我下载了W3Schools的是在那里example使用视频和我的代码看起来像这样

<video width="400" controls> 
    <source src="file:///C:\Users\Gebruiker\Downloads\mov_bbb.mp4" type="video/mp4"> 
    Your browser does not support HTML5 video. 
</video> 

确保您更改URL中的路径。因此,它与您的文件树匹配

+0

尝试'src =“file:/// C:/etc/video.mp4”',它不起作用。 – KoenG

+0

试试这个:'src =“file:/// C:\ Some \ Folder \ onthedrive \ videos \ video.mp4”' 或试试这个'src =“file:/// C:/ Some/Folder/onthedrive /videos/video.mp4“' – NiekF

+0

(出于某种原因,我无法编辑我以前的评论),但是您必须在”file:/// C:\“ 或”文件:/// C:/” – NiekF