简体   繁体   English

如何在HTML中播放视频

[英]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> 

Try to add this on top of your .htaccess file: 尝试将其添加到您的.htaccess文件之上:

AddType video/mp4 mp4 m4v
AddType audio/mp4 m4a
AddType video/ogg ogv
AddType audio/ogg ogg oga
AddType video/webm webm

Here you can read more about it 在这里您可以了解更多有关它的信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM