[英]How to play video in Html
I have problem that play video on website. 我在网站上播放视频时遇到问题。 Firstly I used below code in localy and these code work .
首先,我在本地使用以下代码,这些代码可以正常工作。 But when I public this page video does not play and give "no video with supported format or mime type " this error .I use IIS server in Windows.
但是,当我公开此页面视频时,无法播放并给出“没有支持格式或mime类型的视频”错误。我在Windows中使用IIS服务器。 And this page is working under ASP.NET web site.
并且此页面在ASP.NET网站下工作。 Here is html code:
这是html代码:
<div style="text-align:center"> <button onclick="playPause()">Play/Pause</button> <button onclick="makeBig()">Big</button> <button onclick="makeSmall()">Small</button> <button onclick="makeNormal()">Normal</button> <br> <video width="640" height="360" controls="controls"> <source src="files/Just.mp4" type="video/mp4" /> <object width="640" height="375" type="video/quicktime" data="files/Just.mp4"><!--<![endif]--> <param name="src" value="files/Just.mp4" /> <param name="autoplay" value="true" /> <param name="showlogo" value="false" /> <!--[if gt IE 6]><!--> </object><!--<![endif]--> </video> </div> <script> var myVideo = document.getElementById("video1"); function playPause() { if (myVideo.paused) myVideo.play(); else myVideo.pause(); } function makeBig() { myVideo.width = 560; } function makeSmall() { myVideo.width = 320; } function makeNormal() { myVideo.width = 420; } </script>
You have no id of video1. 您没有视频1的ID。 Put it after the video tag and then it should work
将其放在视频标签之后,然后即可正常工作
<!DOCTYPE html> <html> <body> <div style="text-align:center"> <button onclick="playPause()">Play/Pause</button> <button onclick="makeBig()">Big</button> <button onclick="makeSmall()">Small</button> <button onclick="makeNormal()">Normal</button> <br> <video id="video1" width="420"> <source src="http://www.w3schools.com/html/mov_bbb.mp4" type="video/mp4"> <source src="http://www.w3schools.com/html/mov_bbb.ogg" type="video/ogg"> <param name="autoplay" value="true" /> <param name="showlogo" value="false" / Your browser does not support HTML5 video. </video> </div> <script> var myVideo = document.getElementById("video1"); function playPause() { if (myVideo.paused) myVideo.play(); else myVideo.pause(); } function makeBig() { myVideo.width = 560; } function makeSmall() { myVideo.width = 320; } function makeNormal() { myVideo.width = 420; } </script> </body> </html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.