js 獲取視頻的總時長: <!DOCTYPE html> <html> <head> <title></title> </head> <body> <video id="videoPlayerNew" src="http://vfx.mtime.cn/Video/2019/03/18/mp4/190 ...
js 獲取視頻的總時長:
<!DOCTYPE html> <html> <head> <title></title> </head> <body> <video id="videoPlayerNew" src="http://vfx.mtime.cn/Video/2019/03/18/mp4/190318231014076505.mp4" controls="controls"> your browser does not support the video tag </video> </body> <script type="text/javascript"> var vid = document.getElementById("videoPlayerNew"); vid.onloadedmetadata = function() { console.log('metadata loaded!'); console.log(vid.duration); //列印時長 }; </script> </html>
轉自:https://stackoverflow.com/questions/40763057/trying-to-get-full-video-duration-but-returning-as-nan