2013-03-19 20 views
0

视频在画布上玩不会让我点击控件(暂停,播放,声音等)视频在画布上玩不会让我点击控件(暂停,播放,声音等)

如何使控制同时保持相同的功能和动画。动画工作正常等功能。

代码:

<style> 
       #cvs { 
        position: absolute; 
        top: 0px; 
        left: 0px; 
       } 
      </style> 
<script type='text/javascript' src='http://code.jquery.com/jquery-1.8.3.js'></script> 
     <script type="text/javascript"> 
      var context; 
      var text = ""; 
      var textDirection =""; 

      $(function() 
      { 
       context = document.getElementById("cvs").getContext("2d");    
       setInterval("animate()", 360); 

       textDirection ="right"; 
       textXpos = 5; 
       text = "This is my video..";  
      }); 

      function animate() {    
       // Clear screen 
       context.clearRect(0, 0, 500, 500); 
       context.globalAlpha = 1; 
      //context.fillStyle = '#fff'; 
      // context.fillRect(0, 0, 500, 500);  

       var metrics = context.measureText(text); 
       var textWidth = metrics.width; 
       if (textDirection == "right") { 
        textXpos += 10; 

        if (textXpos > 500 - textWidth) { 
         textDirection = "left"; 
        } 
       } 
       else { 
        textXpos -= 10; 

        if (textXpos < 10) { 
         textDirection = "right"; 
        }      
       } 

       context.font = '20px _sans'; 
       context.fillStyle = 'white'; 
       context.textBaseline = 'top'; 
       context.fillText (text, textXpos, 440);  
       } 
       </script> 
      </head> 
      <body> 
      <div id="page"> 
     <video id="video" autoplay loop> 
      <source id='mp4' 
      src="http://media.w3.org/2010/05/sintel/trailer.mp4" 
      type='video/mp4'> 
      <source id='webm' 
      src="http://media.w3.org/2010/05/sintel/trailer.webm" 
      type='video/webm'> 
      <source id='ogv' 
      src="http://media.w3.org/2010/05/sintel/trailer.ogv" 
      type='video/ogg'> 
      <p>Your user agent does not support the HTML5 Video element.</p> 
     </video> 
       <canvas id="cvs" width="500" height="500"> 
        Your browser does not support the HTML 5 Canvas. 
       </canvas> 
      </div> 
      </body> 
     </html> 

的jsfiddle:http://jsfiddle.net/jBHCN/14/

+0

非常漂亮的动画。控件在哪里? – 2013-03-19 15:36:46

+0

这很正常,因为画布是视频的前面 – 2013-03-19 15:39:41

+0

这是关于完全相同的事情的第三个问题:)我建议重新设想它。 – nycynik 2013-03-19 16:57:21

回答