2016-02-12 67 views
0

當在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] 

回答

1

這不是一個可編輯的屬性,但你可以創建自己的功能檢測變量:

var hasFullscreenEl = !!document.webkitFullscreenElement;

那你以後可以將其設置爲null。不完全確定這是什麼用例,所以讓我知道這是否沒有幫助。

+0

這很有幫助,但該解決方案對我無效。我正在使用document.webkitFullscreenElement來檢測是否點擊了全屏視頻按鈕。如果document.webkitFullscreenElement不能被重置爲null,我無法知道用戶是否多次點擊全屏按鈕,因爲在第一次點擊該按鈕時,該按鈕被設置爲某個對象,那麼它永遠不會被設置回到空,因爲我實際上並沒有用該按鈕全屏播放視頻(我是,但通過使用Android VideoView而不是HTML5/JavaScript,因此它不會重置:/)。 – BrettG

+0

啊,好吧,我現在明白了。我從來沒有試過這樣做,但也許這篇文章將有助於http://www.intheloftstudios.com/blog/detecting-html5-video-fullscreen-and-events –

0

我最終搞清楚了。我只需要手動調用這個。

document.webkitExitFullscreen(); 
相關問題