Webview - 窗口已经聚焦,忽略了焦点增益

时间:2013-12-13 08:58:16

标签: android webview

我的应用已整合Vimeo HTML5WebView。当视频模式(在所有设备上)时,视频工作正常,但当方向更改为横向时,视频开始闪烁。
这发生在平板电脑中 - 7英寸和10英寸平板电脑。当视频闪烁时,我在logcat中收到警告说,窗口已经聚焦,忽略了焦点增益。

请参考下面的logcat。
我尝试在StackOverflow上查看各种问题,但无法获得合适的解决方案。

12-13 14:15:11.730: D/dalvikvm(505): JIT code cache reset in 1 ms (1048548 bytes 8/0)
12-13 14:15:11.740: D/dalvikvm(505): GC_EXPLICIT freed 868K, 25% free 18906K/24960K, paused 5ms+7ms, total 131ms
12-13 14:15:12.521: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4286b2f0 attribute=null, token = android.os.BinderProxy@42458f80
12-13 14:15:12.531: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:12.621: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:16.915: I/AwesomePlayer(180): cache is running low (1.58 secs) , pausing.
12-13 14:15:16.915: W/MediaPlayer(22724): info/warning (703, 1843)
12-13 14:15:16.915: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:16.925: I/MediaPlayer(22724): Info (703,1843)
12-13 14:15:16.925: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:19.928: D/audio_hw_primary(180): out_standby: enter: usecase(1: low-latency-playback)
12-13 14:15:19.988: D/audio_hw_primary(180): stop_output_stream: enter: usecase(1: low-latency-playback)
12-13 14:15:19.988: D/audio_hw_primary(180): disable_audio_route: reset mixer path: low-latency-playback
12-13 14:15:19.988: D/audio_hw_primary(180): disable_snd_device: snd_device(2: speaker)
12-13 14:15:19.998: D/audio_hw_primary(180): stop_output_stream: exit: status(0)
12-13 14:15:19.998: D/audio_hw_primary(180): out_standby: exit
12-13 14:15:27.916: I/AwesomePlayer(180): cache has filled up (6.09 secs), resuming.
12-13 14:15:27.916: W/MediaPlayer(22724): info/warning (702, 0)
12-13 14:15:27.936: D/audio_hw_primary(180): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2)
12-13 14:15:27.936: D/audio_hw_primary(180): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
12-13 14:15:27.936: D/audio_hw_primary(180): enable_snd_device: sending audio calibration for snd_device(2) acdb_id(14)
12-13 14:15:27.936: D/ACDB-LOADER(180): ACDB -> send_afe_cal
12-13 14:15:27.936: D/audio_hw_primary(180): enable_snd_device: snd_device(2: speaker)
12-13 14:15:27.946: D/audio_hw_primary(180): enable_audio_route: apply mixer path: low-latency-playback
12-13 14:15:27.956: D/audio_hw_primary(180): start_output_stream: exit
12-13 14:15:28.016: I/MediaPlayer(22724): Info (702,0)
12-13 14:15:29.608: I/InputReader(505): Reconfiguring input devices.  changes=0x00000004
12-13 14:15:29.608: I/InputReader(505): Device reconfigured: id=6, name='elan-touchscreen', size 1200x1920, orientation 1, mode 1, display id 0
12-13 14:15:29.608: I/InputReader(505): Reconfiguring input devices.  changes=0x00000004
12-13 14:15:29.608: I/InputReader(505): Device reconfigured: id=6, name='elan-touchscreen', size 1200x1920, orientation 1, mode 1, display id 0
12-13 14:15:29.608: I/ActivityManager(505): Config changes=1480 {1.0 404mcc?mnc en_US ldltr sw600dp w960dp h527dp 320dpi lrg land finger -keyb/v/h -nav/h s.51}
12-13 14:15:29.678: D/audio_hw_primary(180): adev_set_parameters: enter: rotation=90
12-13 14:15:29.678: D/audio_hw_primary(180): adev_set_parameters: exit with code(0)
12-13 14:15:29.748: D/PhoneStatusBar(587): mSettingsPanelGravity = 8388661
12-13 14:15:29.808: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:29.828: I/WindowManager(505): Screen frozen for +274ms due to Window{4290b200 u0 Panel:com.xx.xxx/com.xx.xxx.WebViewActivity}
12-13 14:15:29.908: E/CABL(203): MSMFB_HISTOGRAM_STOP failed!
12-13 14:15:31.970: D/dalvikvm(505): GC_EXPLICIT freed 858K, 25% free 18826K/24960K, paused 7ms+5ms, total 120ms
12-13 14:15:32.911: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4283d658 attribute=null, token = android.os.BinderProxy@42458f80
12-13 14:15:32.921: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:32.961: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:35.924: I/AwesomePlayer(180): cache is running low (1.84 secs) , pausing.
12-13 14:15:35.934: W/MediaPlayer(22724): info/warning (703, 1811)
12-13 14:15:35.934: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:35.934: I/MediaPlayer(22724): Info (703,1811)
12-13 14:15:35.934: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:36.064: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@423e5920 attribute=null, token = android.os.BinderProxy@42458f80
12-13 14:15:36.074: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:36.184: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:36.785: W/MediaPlayer(22724): info/warning (702, 0)
12-13 14:15:36.785: I/MediaPlayer(22724): Info (702,0)
12-13 14:15:37.045: I/NuCachedSource2(180): new range: offset= 32665175
12-13 14:15:38.967: D/audio_hw_primary(180): out_standby: enter: usecase(1: low-latency-playback)
12-13 14:15:39.007: D/audio_hw_primary(180): stop_output_stream: enter: usecase(1: low-latency-playback)
12-13 14:15:39.007: D/audio_hw_primary(180): disable_audio_route: reset mixer path: low-latency-playback
12-13 14:15:39.007: D/audio_hw_primary(180): disable_snd_device: snd_device(2: speaker)
12-13 14:15:39.007: D/audio_hw_primary(180): stop_output_stream: exit: status(0)
12-13 14:15:39.007: D/audio_hw_primary(180): out_standby: exit
12-13 14:15:39.978: D/audio_hw_primary(180): start_output_stream: enter: usecase(1: low-latency-playback) devices(0x2)
12-13 14:15:39.978: D/audio_hw_primary(180): select_devices: out_snd_device(2: speaker) in_snd_device(0: none)
12-13 14:15:39.978: D/audio_hw_primary(180): enable_snd_device: sending audio calibration for snd_device(2) acdb_id(14)
12-13 14:15:39.978: D/ACDB-LOADER(180): ACDB -> send_afe_cal
12-13 14:15:39.978: D/audio_hw_primary(180): enable_snd_device: snd_device(2: speaker)
12-13 14:15:39.978: D/audio_hw_primary(180): enable_audio_route: apply mixer path: low-latency-playback
12-13 14:15:39.978: I/AwesomePlayer(180): cache is running low (0.07 secs) , pausing.
12-13 14:15:39.978: W/MediaPlayer(22724): info/warning (703, 1625)
12-13 14:15:39.978: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:39.978: W/MediaPlayer(22724): info/warning (702, 0)
12-13 14:15:39.988: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:39.988: D/audio_hw_primary(180): start_output_stream: exit
12-13 14:15:40.008: V/PhoneStatusBar(587): setLightsOn(true)
12-13 14:15:40.088: I/MediaPlayer(22724): Info (703,1625)
12-13 14:15:40.088: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:40.088: I/MediaPlayer(22724): Info (702,0)
12-13 14:15:40.088: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4221e640 attribute=null, token = android.os.BinderProxy@42458f80
12-13 14:15:40.969: I/AwesomePlayer(180): cache is running low (1.45 secs) , pausing.
12-13 14:15:40.969: W/MediaPlayer(22724): info/warning (703, 1625)
12-13 14:15:40.969: W/MediaPlayer(22724): info/warning (701, 0)
12-13 14:15:40.969: I/MediaPlayer(22724): Info (703,1625)
12-13 14:15:40.969: I/MediaPlayer(22724): Info (701,0)
12-13 14:15:42.640: D/dalvikvm(22724): GC_FOR_ALLOC freed 420K, 4% free 11555K/12012K, paused 24ms, total 24ms
12-13 14:15:43.101: W/InputMethodManagerService(505): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4215b9e0 attribute=null, token = android.os.BinderProxy@42458f80

如果webview代码有帮助,请告诉我,我会将其添加到我的问题中。从我在StackOverflow上看到的问题,我觉得,这可能是一个配置问题,在我的webview代码中,我已经覆盖了onConfigurationChanged()并且还包括了android:configChanges到WebViewActivity。

@Override
public void onConfigurationChanged(Configuration newConfig) {
    super.onConfigurationChanged(newConfig);
}
    <activity android:name=".WebViewActivity" 
     android:configChanges="keyboardHidden|orientation|screenSize"/>

感谢您的帮助!!!

2 个答案:

答案 0 :(得分:1)

放置

android:configChanges="orientation"

对于您的活动,您向系统指示您的活动将处理方向更改。但你并没有真正做任何事情,因为你所做的只是:

super.onConfigurationChanged(newConfig);

那么,如何解决您的问题?

  1. 您说过,只有在大屏幕(平板电脑)上发生方向更改时才会遇到问题。从纵向更改为横向时。在电话设备上发生方向更改时,Yo看不到问题。 这让我觉得视频质量可能不足以在横向模式下播放。真的吗?即如果您最初在横向模式下开始活动,您是否仍然看到闪烁?

  2. 您确定这不是特定于设备的问题吗?那么你所描述的这个问题是出现在所有大屏幕设备上还是只是你正在测试的那个?

  3. 您说过使用Vimeo HTML5WebView呈现视频。您是否尝试过平台提供的常规WebView,并且框架提供的小部件也会出现类似的问题?

  4. 最后但并非最不重要的是,您始终可以保存播放器的状态(例如视频在方向之前的时间戳),然后使用该状态在方向更改后恢复您的网页视图。为此,请自行停止处理配置,然后按照Saving Activity StateHandling configuration changes以及Handling Runtime Changes中提到的准则进行操作。如果你完全相信你可以自己处理配置更改,那么继续这样做但不要只调用super并期望系统为你神奇地处理活动对象状态。

  5. 希望这有帮助。

答案 1 :(得分:0)

每个人所做的最佳解决方案是在模式之间进行更改,从横向到纵向或纵向到横向暂停视频并留下webview的错误,即将焦点设置为webview,并在完成webview恢复后获得焦点并播放视频。 offcouse你需要做一些额外的java脚本编码和javascript桥编码,但解决方案将工作。