Create a new html5 video object with jQuery -


how can create video element jquery, , add it's properties control true (<video control>), add , remove video sources (<source src='http://somesite.com/somevideo.mp4'), etc?

i set it's options before loading (like autoplay, true or false, etc)

i tried without success (it worked images, not video):

$( document ).ready(function() { var photo = $('<img />', {               id: 'photo',               src: 'http://lorempixel.com/400/200/city/',               alt: ''               }); photo.appendto($('#gallery'));  var video = document.createelement('video');     alert( video.tosource() ); //for testing     video.id = 'video';     video.source.src = 'http://video-js.zencoder.com/oceans-clip.mp4';     video.type = 'video/mp4';     video.control = true; video.appendto($('#gallery')); }); 

jsfiddle: https://jsfiddle.net/9cnaz3ju/1/

like this:

var video = $('<video />', {     id: 'video',     src: 'http://video-js.zencoder.com/oceans-clip.mp4',     type: 'video/mp4',     controls: true }); video.appendto($('#gallery')); 

jsfiddle example

    var photo = $('<img />', {          id: 'photo',          src: 'http://lorempixel.com/400/200/city/',          alt: ''      });      photo.appendto($('#gallery'));        var video = $('<video />', {          id: 'video',          src: 'http://video-js.zencoder.com/oceans-clip.mp4',          type: 'video/mp4',          controls: true      });      video.appendto($('#gallery'));
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>  <div id="gallery"></div>

just follow same basic format see image element.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -