简体   繁体   中英

accessing html5 video elements using the api

trying to access various properties of my video tag. started looking at the HTML5 video api for some answers.

here is my basic code that i am playing with...

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

i am trying to use this line document.write(myVideo.isEnabled); but get undefined. i have limeted experience in web programming, so please excuse if there are any obvious problems.

i seemed to think i could do this by reading this part section of the api http://www.w3.org/TR/html5/video.html#media-resources-with-multiple-media-tracks

i guess i just really don't know how to use it any help?

Please note that the <video> tag object does not have a isEnabled attribute. You were looking at the MultipleTrackList interface which is not the same thing. Check out: http://www.w3schools.com/html5/tag_video.asp and https://developer.mozilla.org/en/HTML/Element/video and https://developer.mozilla.org/en/Using_HTML5_audio_and_video

Also, instead of using document.write() to debug, use alert( something ) or better yet (if you are working on chrome or firefox with firebug install) use console.log( something ) and see the output in the console (use f12 in chrome to see it).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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