javascript - Duration of Video in Express.js: NaN -
i trying total duration of video, in express.js. below have shown code in jade. include video in webpage.
video(width='320', height='240', controls='controls') source(src='/images/video.mp4', type='video/ogg', id='thevideo')
then call folowing function on button click.
function getcurrenttime() { var video = document.createelement('video'); var time = video.duration; document.getelementbyid('mytime').value=time; }
'mytime' text box.
input(id='mytime', size='5')
but when run video, duration nan. tried read posts on why happens, , apparently related "byte" problem, or sending headers or that. can please explain me reason why happening , how can fix it? thanks.
try this:
jade:
video(width='320', height='240', controls='controls', id='thevideo') source(src='/images/video.mp4', type='video/ogg')
js:
window.addeventlistener('load', function(){ var video = document.getelementbyid('thevideo'); video.addeventlistener('loadedmetadata', function() { console.log(math.round(video.duration)); }); });
Comments
Post a Comment