Julien
Julien

Reputation: 1980

HTML5 Video in ajax call

I want to call a video in ajax query, it work but not corectly (It lacks the control buttons of the video player)
Here is my ajax code:

$.ajax({
    context: document.body,
    url: "/?get=json&act=video", 
    type: "get", 
    success: function(html) {  
          // console.log(JSON.parse(html)); 
          var a = JSON.parse(html);
          var returnVideo = "";
          a.forEach(function(element) {
          console.log(element);

            returnVideo += '    <div class="uk-card uk-card-hover uk-card-default">';   
            returnVideo += '        <div class="uk-card-media-top">'; 
            returnVideo += '    <video  width="" height="">';   
            returnVideo += '        <source src="'+element.gameClipUris[0].uri+'" type="video/mp4">';   
            returnVideo += '    </video>';  
            returnVideo += '        </div>';    
            returnVideo += '    </div><br />';  

          });
          $('#loading').hide("slow");
          $('#retourForm').append(returnVideo);
        }
});

The output: enter image description here

It lacks the control buttons of the video player!
I have test to add player with url hardcoded and it work (right in image)...

enter image description here

So I guess I can not load html5 player from javascript?

Upvotes: 4

Views: 3469

Answers (1)

Gaurav
Gaurav

Reputation: 1233

You can add controls attribute to the video tag like <video controls></video>. For more info read about video tag.

Upvotes: 1

Related Questions