2017-04-12 73 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