Do you have any idea why I’m getting an error “Can’t create event listener of null” from this:
var my;
my.newVidObj = document.createElement('video');
my.newVidObj.src = "vid-source.webm";
my.newVidObj.load();
my.newVidObj.addEventListener("play", function() {
// Do something
}, false);
Also, is there any way to use video tag methods on jquery objects (creating the video tag via jquery, for example)?
I edited the below answer to be correct, but it needs to be peer reviewed. Here is the solution:
var vid = $("<video />", {
id: "my-HTML5-video",
src: "video.webm"
}).bind("play", function(){
alert('test');
}).appendTo("body")[0].play();
Check out these links:
http://www.chipwreck.de/blog/2010/03/01/html-5-video-dom-attributes-and-events/
http://www.dev.opera.com/articles/view/introduction-html5-video/
http://www.chipwreck.de/blog/2010/02/23/html-5-video-test-area/
I think it should be:
Correction by OP: