簡體   English   中英

使用api訪問html5視頻元素

[英]accessing html5 video elements using the api

嘗試訪問我的視頻標簽的各種屬性。 開始查看HTML5視頻API的一些答案。

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

<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>

我正在嘗試使用這一行document.write(myVideo.isEnabled); 但變得不確定。 我有豐富的Web編程經驗,所以如果有任何明顯的問題,請原諒。

我似乎認為我可以通過閱讀api http://www.w3.org/TR/html5/video.html#media-resources-with-multiple-media-tracks的這一部分來做到這一點

我想我真的不知道該如何使用它的幫助?

請注意, <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()進行調試,而使用alert(something)或更好(如果您正在使用Firebug安裝在chrome或firefox上工作),請使用console.log(something)並在控制台中查看輸出(使用鉻中的f12即可查看)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM