How does Youtube's HTML5 video player control buffering?

前端 未结 4 532
小鲜肉
小鲜肉 2021-01-29 20:49

I was watching a youtube video and I decided to investigate some parts of its video player. I noticed that unlike most HTML5 video I have seen, Youtube\'s video player does not

4条回答
  •  孤独总比滥情好
    2021-01-29 21:12

    there is a canvas element in the page ,Maybe This Will Help http://html5doctor.com/video-canvas-magic/

    we knew the video is been segmented,the question is how to stitch them together.i think the real video element doesn't do the play work,it support the datasource,and draw the seagments each frame to the canvas element。

    var v = document.getElementById('v'); 
    var canvas = document.getElementById('c');
    v.addEventListener('play', function(){ 
       if(v.paused || v.ended) return false; 
       c.drawImage(v,0,0,w,h); 
       setTimeout(draw,20,v,c,w,h); 
    },false);
    

提交回复
热议问题