while creating a video player using html5 i try to load the video from other source and generated the markup according to it. as shown below
var _vid = document.getElementById('vid');
$('#vid').html('<video width=300 height=200 id="vid" controls autoplay src="http://172.16.25.214/gems1_video/30032011.mp4"></video>');
var video = document.getElementById('video');
_vid = $(_vid).find('video').get(0);
console.info(_vid);
_vid.load();
_vid.play();
when i open this file in the local Host it is working fine, but when i hit the url from the other server it shows _vid is a undefined one any idea abo开发者_StackOverflowut it..?
You are making references to elements that have not been created. Also I couldn't get access to the video file.
I re-wrote the sample and linked to a video on my own server, you can see it here:
http://jsfiddle.net/thebeebs/Ye3Nf/
P.S because your code only references mp4 it will only play in IE9, Safari and chrome(although chrome will drop support for H.264 soon). You should add a source of WebM and maybe even ogg too.
var _vid = document.getElementById('vid');
This should not work until you not created the DOM element. You're trying to get an element that is not exist yet.
精彩评论