I am trying to add a new VideoJS object and set it up entirely from JS, without having a DOM video element.
The result is that the video is loaded but there aren’t any VideoJS controls.
Here is the code:
obj = document.createElement('video');
$(obj).attr('id', 'example_video_1');
$(obj).attr('class', 'video-js vjs-default-skin');
var source = document.createElement('source');
$(source).attr('src', path);
$(source).attr('type', 'video/mp4');
$(obj).append(source);
$("#content").append(obj);
_V_("example_video_1", {}, function () {
//
}
});
I will appreciate any help, thanks!
Okay took a look at video-js, it’s quite nice. Try this:
HTML:
JavaScript:
Working example on jsbin.
Updates:
As polarblau pointed out in a comment the
jQuery.attr()can take an object rather than having to calljQuery.attr()multiple times like in my first example.note: The below is just an example and not a working demo.