[英]Getting video info (width, height, duration) using JavaScript
我需要在客戶端驗證視頻並檢查視頻的寬度,高度和持續時間。 僅檢查文件擴展名是不夠的; 它必須確保使用正確的編解碼器和包裝器。 我該怎么做?
嘗試這個:
<video id="my_id" src="music.mp4"></video>
var video_id = document.getElementById("my_id"); video_id.videoHeight;
video_id.videoWidth;
看看這個:
<video id="foo" src="foo.mp4"></video>
var vid = document.getElementById("foo");
vid.videoHeight; // returns the intrinsic height of the video
vid.videoWidth; // returns the intrinsic width of the video
來源(HTML5規范): http : //www.w3.org/TR/html5/video.html#video
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.