user2284926
user2284926

Reputation: 651

Embedding YouTube Videos doesn't work in local HTML files (using file:// URL)

Why does embedding videos from youtube work on my local host but not when it is in C drive

eg: http://localhost/test/test.html                (embedded video works ) 

file:///C:/Users/AUser%20name/Desktop/test/test.html  (embedded video does not work)

this is my snippet of code to embedd the video

<object width="560" height="315"><param name="movie" value="//www.youtube.com/v/0l-
7IGRsORI?hl=en_US&amp;version=3"></param><param name="allowFullScreen" value="true">
</param><param name="allowscriptaccess" value="always"></param><embed
src="//www.youtube.com/v/0l-7IGRsORI?hl=en_US&amp;version=3" type="application/x-
shockwave-flash" width="560" height="315" allowscriptaccess="always"
allowfullscreen="true"></embed></object>

Upvotes: 3

Views: 5051

Answers (1)

seymar
seymar

Reputation: 4063

Because you use the // at the beginning of the url, meaning you inherit the currently used protocol. At your host it is http:// (good), but at your C drive it's file:// (bad).

So just use http:// instead of //:

<object width="560" height="315">
    <!-- See: value="http://.. -->
    <param name="movie" value="http://www.youtube.com/v/0l-7IGRsORI?hl=en_US&amp;version=3"></param>
    <param name="allowFullScreen" value="true"></param>
    <param name="allowscriptaccess" value="always"></param>

    <!-- See: src="http://.. -->
    <embed src="http://www.youtube.com/v/0l-7IGRsORI?hl=en_US&amp;version=3" type="application/x-shockwave-flash" width="560" height="315" allowscriptaccess="always" allowfullscreen="true"></embed>
</object>

Upvotes: 7

Related Questions