2012-01-06 60 views
1

試圖訪問我的視頻標籤的各種屬性。開始尋找HTML5視頻api的一些答案。使用api訪問html5視頻元素

這裏是我的基本代碼,我正在玩...

<body> 
<div style="text-align:center">  
    <video id="video" onClick="cut()" src="test.mp4" autoplay="autoplay" > 

     not supported 
    </video> 
</div> 

<script type="text/javascript"> 

    var myVideo=document.getElementById("video"); 
    var currentClip=0; 
    document.write(myVideo.isEnabled); // trying to print this out to see what happens 

    function cut() 
     { 
     if (currentClip == 0){ 
      myVideo.src = "bend.mp4" 
      currentClip = 1; 
      } 
     else{ 
      myVideo.src = "test.mp4"; 
      currentClip = 0; 
      } 
     } 

    function playPause(){ 
     if (myVideo.paused){ 
      myVideo.play(); 
     } 
     else{ 
      myVideo.pause(); 
      } 
     } 

    function makeBig(){ 
     myVideo.height=(myVideo.videoHeight*2); 
     } 

    function makeSmall(){ 
     myVideo.height=(myVideo.videoHeight/2); 
     } 

    function makeNormal(){ 
     myVideo.height=(myVideo.videoHeight); 
     } 

</script> 

我將嘗試使用該行 文件撰寫(myVideo.isEnabled); 但未定義。我已經在網絡編程方面提供過經驗,所以請原諒,如果有任何明顯的問題。

我似乎覺得我能做到這一點通過讀取API http://www.w3.org/TR/html5/video.html#media-resources-with-multiple-media-tracks

我想我只是真的不知道如何使用它的任何幫助,這部分款?

回答

0

請注意,<video>標記對象沒有isEnabled屬性。你正在看MultipleTrackList接口,這是不一樣的事情。 退房:http://www.w3schools.com/html5/tag_video.asphttps://developer.mozilla.org/en/HTML/Element/videohttps://developer.mozilla.org/en/Using_HTML5_audio_and_video

此外,而不是使用document.write()來調試,使用的警報(東西)或者更好(如果你使用的是Chrome或Firefox正在與螢火蟲安裝)使用控制檯。記錄(某些東西)並查看控制檯中的輸出(在chrome中使用f12來查看它)。