Change script to display video in Html5

4

How do I make this script show a video in HTML5 instead of in Flash Player? My script looks like this:

In this script it injects the video link into the flash player, I would like to replace that with an HTML5 of type <video class="" width="100%" controls preload="auto" autoplay poster="" src=" "></video>

<script type="text/javascript">
    // Which flash versions are needed for given format
    var FLASH_VERSIONS = {
        '7/0/0': [5],
        '9/0/115': [18, 22, 33, 34, 35, 37, 38, 59, 78, 82, 83, 84, 85, 120, 121],
    }

    var ts = Math.round((new Date()).getTime() / 1000);
</script>
    
asked by anonymous 15.09.2015 / 20:05

1 answer

3

Look for tutorials that teach videos in HTML 5.

<video controls>
  <source src="foo.ogg" type="video/ogg">
  <source src="foo.mp4" type="video/mp4">
  Seu navegador não suporta o elemento <code>video</code>.
</video>

Example by clicking a button to play a video:

$('#playMovie1').click(function(){
    $('#movie1')[0].play();
});

I have not been able to create a video player with JavaScript, but anything of a append of an element of type video and manipulate it with JavaScript.

References (I hope these links are useful to you):

link link link link

EDIT

function addSourceToVideo(element, src, type) {
    var source = document.createElement('source');

    source.src = src;
    source.type = type;

    element.appendChild(source);
}

var video = document.createElement('video');

document.body.appendChild(video);

addSourceToVideo(video, 'http://upload.wikimedia.org/wikipedia/commons/7/79/Big_Buck_Bunny_small.ogv', 'video/ogg');

video.play();
    
15.09.2015 / 21:34