How to display youtube video on HTML page? [closed]

你。 提交于 2019-12-23 03:09:13

问题


First embeded src youtube video link is

 <html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
 <body>
<div>
    <object width="218" height="137"><param name="movie" value="http://www.youtube.com/v/jpiU5Y8luOQ&hl=en_US&fs=1&"></param>
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed src="http://www.youtube.com/v/jpiU5Y8luOQ&hl=en_US&fs=1&" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="218" height="137">
    </embed>
    </object>
</div>
</body>
</html>

Second embeded src Video link is

 <html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title></title>
</head>
<body>
<div>
    <object width="218" height="137"><param name="movie" value="http://www.youtube.com/watch?v=LwkeMx_OJxg&feature=related">
        <param name="allowFullScreen" value="true"></param>
        <param name="allowscriptaccess" value="always"></param>
        <embed src="http://www.youtube.com/watch?v=LwkeMx_OJxg&feature=related" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="218" height="137">
        </embed>
    </object>
</div>
</body>
</html>

The first html cod display video file on browser but the second didn't display. Can't the second one dispaly due to different video file type? Please guide me how to do.

                                            Thanks in advance

回答1:


On the second embed, you're linking the object directly to the watch page, which is not a valid video. You're providing it with a text/html page, not a video.

You can use this IFrame for the second one, and adjust the height/width as needed:

<iframe width="420" height="315" src="http://www.youtube.com/embed/LwkeMx_OJxg" frameborder="0" allowfullscreen></iframe>



回答2:


Youtube provides you with a sample code itself. You can't embed the videos, you'll need to use an iframe.

Read this




回答3:


When you right-click on the video page in Youtube, it gives you this code:

<object style="height: 137px; width: 218px">
<param name="movie" value="http://www.youtube.com/v/LwkeMx_OJxg?version=3&feature=player_detailpage">
<param name="allowFullScreen" value="true">
<param name="allowScriptAccess" value="always">
    <embed src="http://www.youtube.com/v/LwkeMx_OJxg?version=3&feature=player_detailpage" 
     type="application/x-shockwave-flash"
     allowfullscreen="true" allowScriptAccess="always" width="218" height="137">
</object>

Which works (I changed the width/height as per your example to check it works, and it does



来源:https://stackoverflow.com/questions/10344387/how-to-display-youtube-video-on-html-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!