2015-02-10 48 views
0

我試圖隱藏視頻的寬度:得到高度和

video.height // never worked 
video.offsetHeight // worked when video was visible, now returning 0 

爲只顯示已處理的視頻的目的,我一直隱藏在視頻元素,如果我畫它在一定的時間間隔在屏幕上,下面的代碼工作(甚至witht EH視頻隱藏),

var video = document.getElementById('someVid'); 
var canvas = document.getElementById('someCanvas'); 
var ctx = canvas.getContext('2d'); 
ctx.drawImage(video, 0, 0, canvas.height, canvas.width); 

我需要一些處理的高度和寬度,繪畫之前,因此新的拉繩是:

ctx.drawImage(video, x, y, w, h, 0, 0, canvas.height, canvas.width); 

用於計算那個x,y,w,h我需要隱藏視頻的高度,寬度。

p.s:無需IE支持,只需要firefox和chrome。

回答

1

OK,找到了解決辦法,

var height = video.videoHeight; 
var width = video.videoWidth; 

回報的內在價值......

source