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
添加回答
举报