當在Android WebView中單擊html5視頻標籤的全屏按鈕時,document.webkitFullscreenElement被設置爲我單擊的視頻(根據打印輸出)。有沒有辦法我可以手動將其設置爲null?如何將文檔屬性(如document.webkitFullscreenElement)設置爲null?
我打全屏的視頻
console.log(document.webkitFullscreenElement); //null
之前我打全屏的視頻後
console.log(document.webkitFullscreenElement); //[object HTMLVideoElement]
設置爲null
document.webkitFullscreenElement = null;
集後爲空
console.log(document.webkitFullscreenElement); //[object HTMLVideoElement]
這很有幫助,但該解決方案對我無效。我正在使用document.webkitFullscreenElement來檢測是否點擊了全屏視頻按鈕。如果document.webkitFullscreenElement不能被重置爲null,我無法知道用戶是否多次點擊全屏按鈕,因爲在第一次點擊該按鈕時,該按鈕被設置爲某個對象,那麼它永遠不會被設置回到空,因爲我實際上並沒有用該按鈕全屏播放視頻(我是,但通過使用Android VideoView而不是HTML5/JavaScript,因此它不會重置:/)。 – BrettG
啊,好吧,我現在明白了。我從來沒有試過這樣做,但也許這篇文章將有助於http://www.intheloftstudios.com/blog/detecting-html5-video-fullscreen-and-events –