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')); 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
Post a Comment