html5 controls property

轉載自http://msdn.microsoft.com/zh-tw/library/ie/ff974746%28v=vs.85%29.aspx
 
<!DOCTYPE html>
<html>
  <head>
    <title>Simple Video Example</title>
      <!-- Uncomment the following tag when developing on a local or intranet computer -->
      <!-- <meta http-equiv='X-UA-Compatible' content="IE=edge" /> -->
        
     <script>
         function hidecontrol(e) {
           // Set controls to true or false based on their current state
           var video = document.getElementById('video1');
           if (video.controls == true) {
             // Controls are binary, true if there, false if not
             video.removeAttribute("controls"); 
             e.innerHTML = "Show controls";
           } else {
             // Controls are binary, true if there, false if not
             video.setAttribute("controls", true); 
             e.innerHTML = "Hide controls";
           }
         }

         function playVideo(e) {
           var video = document.getElementById('video1');      //video element
           //  Toggle between play and pause based on the paused property
           if (video.paused) {
             var input = document.getElementById('videoFile');   //text box
             if (input.value) {
               //  Only load a video file when the text field changes
               if (input.value != video.src) {
                 video.src = input.value;
               }
               video.play();
               e.innerHTML = "Pause";
             }
           } else {
             video.pause();
             e.innerHTML = "Play";
           }
           
         }
     </script>
</head>
<body>
<video id="video1" controls >HTML5 video is not supported</video><br />
<input type="text" id="videoFile" size="60" placeholder="Enter video file URL here"/>
  <button οnclick="playVideo(this);">Play</button>
  <button οnclick="hidecontrol(this);">Hide controls</button>
</body>
</html> 

===============================================================================================

如果html5的control bar 顯示有問題,則可以include javascript and css

<html>
<head>
<title>play HTTP </title>
<link href="http://vjs.zencdn.net/4.3/video-js.css" rel="stylesheet">
<script src="http://vjs.zencdn.net/4.3/video.js"></script>
</head>
<body>
<center>
        <video id="my_video" class="video-js vjs-default-skin" preload="auto" width="720" height="360"
                poster="my_video_poster.png" data-setup="{}" controls autoplay>
                <source src="http://media.w3.org/2010/05/sintel/trailer.mp4">
        </video>
</center>
</body>
</html>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值