2

My application has Vimeo HTML5WebView integrated. The video is working fine, when it is portrait mode(on all devices), but when the orientation is changed to landscape, the video starts to flicker.
This is happening in tablets - in 7 and 10 inch tablets. When the video flickers, I get a warning in the logcat saying, the window already focused, ignored focus gain.

Please refer to the logcat below.
I tried looking at various questions on StackOverflow, but couldn't get a decent solution.

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

Please let me know, if the webview code helps, and I will add it to my question. From the questions that I have seen on StackOverflow, I feel, this might be a configuration issue, and in my code for webview, I have overwritten, onConfigurationChanged() and also included, android:configChanges to WebViewActivity.

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

Thanks for your help!!!

Bhavin Nattar
  • 3,189
  • 2
  • 22
  • 30
Vamsi Challa
  • 11,038
  • 31
  • 99
  • 149
  • i too hv webview intergated with vimeo video but it does not happens this way Refer :http://stackoverflow.com/questions/15895437/how-to-play-vimeo-video-using-iframe-in-webview – KOTIOS Dec 28 '13 at 16:30

2 Answers2

1

By placing

android:configChanges="orientation"

for your activity, you are indicating to the system that your activity will handle the orientation change. But you are not really doing anything because all you are doing is:

super.onConfigurationChanged(newConfig);

So, how to solve your issue?

  1. You said you are having the issue when orientation changes occur only on large screens (tablets) and esp. when changing from portrait to landscape. Yo don't see the issue when orientation changes occur on phone devices. It makes me think that the video quality might not be of good enough quality to be played in landscape mode. Is that true? i.e if you start your activity in the landscape mode initially, do you still see the flickering?

  2. Are you sure it's not a device specific issue? i.e does this issue you described occur on all large screen devices or just one that you are testing?

  3. You have said you are using Vimeo HTML5WebView to render the video. Have you tried on a regular WebView that the platform provides and does similar issues happen with the framework provided widget as well?

  4. Last but not least, you can always save the state of the player (like the timestamp where the video is before orientation) and then use that state to restore your webview after orientation changes. To do that, stop handling configuration yourself and then follow the guidelines mentioned in Saving Activity State and Handling configuration changes and Handling Runtime Changes. If you are absolutely convinced you can handle config changes yourself, then go ahead and do it but don't just call super and expect the system to magically handle the activities object states for you.

Hope this helps.

VJ Vélan Solutions
  • 6,434
  • 5
  • 49
  • 63
  • 1. Yeah the videos are of good quality. It plays well in landscape mode. 2.This I am not sure of, all the devices that I am testing are of 4.3. The video plays well on 4.4 but then there are improvements in 4.4, so really cannot say that its 4.3 device specific. Will test it on some other tablets. 3. The Vimeo videos are HTML5 and hence normal videos doesn't play the video. 4. Will look into it. – Vamsi Challa Dec 22 '13 at 05:33
0

Best solution every one does is during changes between modes landscape to portrait or portrait to landscape pause the video and leave foucus of webview ie set focus false to webview and after complete restore of the webview gain the focus and play the video. offcouse u need to do some extra java script coding and javascript bridge coding but solution will work.

Sush
  • 3,864
  • 2
  • 17
  • 35