1 回答

TA貢獻1805條經驗 獲得超9個贊
我還沒有找到答案,但到目前為止我正在發布我的發現,希望它可以幫助某人。
版本:cordova-android8.1.0
我發現了什么
問題來自這樣一個事實,即要全屏顯示 Youtube 視頻,SystemWebChromeClient調用CordovaWebViewImpl.showCustomView()方法。通過這樣做,新視圖似乎在 Cordova 能夠onDispatchKeyEvent()將backbutton事件發送到 JavaScript 端之前捕獲后退按鈕事件。
這是一些日志,為了清楚起見,添加了注釋
// Video is fullscreen, and then dismissed with the onscreen minimize button
D/CordovaWebViewImpl: showCustomView : showing Custom View + view = android.widget.FrameLayout{a7cc344 V.E...... ......I. 0,0-0,0}
D/CordovaWebViewImpl: hideCustomView : Hiding Custom View : mCustomView = android.widget.FrameLayout{a7cc344 V.E...... .......D 0,0-1080,1704}
// While the video is not displayed fullscreen, the back button event is correctly caught and sent to the JS side
D/CordovaWebViewImpl: onDispatchKeyEvent : isBackButton = true mCustomView = null
// Once again in fullscreen, then click on the back button
D/CordovaWebViewImpl: showCustomView : showing Custom View + view = android.widget.FrameLayout{fa6d336 V.E...... ......I. 0,0-0,0}
// No back button event caught
// A destroy lifecycle event is sent (from the video FrameLayout handling?) and handleDestroy() is called
D/CordovaWebViewImpl: handleDestroy : load about:blank
D/CordovaWebViewImpl: >>> loadUrl(about:blank)
W/cr_AwContents: WebView.destroy() called while WebView is still attached to window.
D/CordovaWebViewImpl: hideCustomView : Hiding Custom View : mCustomView = android.widget.FrameLayout{a7cc344 V.E...... .......D 0,0-1080,1704}
我試過的
創建 的子類FrameLayout,并覆蓋onKeyDown()和onKeyUp(),將其用于showCustomerView()
然后視頻不再顯示。
文檔
https://developer.android.com/reference/android/widget/FrameLayout
添加回答
舉報