Is html5 doctype necessary for the functioning of the video tag?

just because the video tag is used, should the whole page be HTML5 ??

I didn’t think so ... what do you think?

I have an understanding that the video tag ( <video>) is not strict HTML5 (partly because strict does not exist yet), and HTML5 is not used or is not required to implement the video tag - that the tag can work in HTML4 / plain old HTML and phtml docs ... am i wrong?

+3
source share
5 answers

W3C, , <video> HTML5. , HTML, , doctype.

+3

, IE9 DOCTYPE. HTML5 DOCTYPE - HTML4 .

( , , DOCTYPE HTML2/3 - svg doctype, math ...)

0

HTML5 DOCTYPE. .

, . , -.

0

, xHtml 1.0 HTML5.

jQuery : https://github.com/charlycoste/xhtml-video

: http://demo.ccoste.fr/video

, , HTML5, , , !

javascript , , <object>.

:

  • ( ) , DOM:

    var video = document.createElement('video');
    
  • canvas , DOM:

    var canvas = document.createElement('canvas');
    
  • img DOM.

    // var parent = ... ;
    // var width = ...;
    // var height = ...;
    var img = document.createElement('img');
    
    img.setAttribute('width', width);
    img.setAttribute('height', height);
    
    parent.appendChild(img);
    
  • (video.play()), ( , DOM, DOM xhtml 1.0)

    canvas.getContext("2d").drawImage(video, 0, 0, width, height);
    
  • , toDataURL() canvas base64 src img.

    img.setAttribute('src', canvas.toDataURL());
    

, javascript DOM img DOM. , HTML5 , HTML5.

Performance aspect: since this leads to a very intensive consumption process, playback may flicker ... To avoid this, you can reduce the rendering quality by using jpeg compression as follows: canvas.toDataURL('image/jpeg', quality)where qualityis the value between 0 and 1.

0
source

Source: https://habr.com/ru/post/1752725/


All Articles