2017-07-14 65 views
7

我的全屏视频web视图几乎总是在打开后立即关闭,有时会起作用。几乎每次我点击YouTube视频上的全屏按钮时,您都可以看到屏幕全屏闪烁并回到原始画面。这可能是什么原因?为什么我的全屏webview在打开后不断关闭?

该webview显示在tablayout/viewpager设置与其他片段。

我已经使用这个代码显示视频: https://github.com/cprcrack/VideoEnabledWebView

现在我用这一个https://github.com/GoogleChrome/chromium-webview-samples/blob/master/fullscreen-video-sample/app/src/main/java/fullscreenvideosample/android/chrome/google/com/fullscreenvideosample/MainActivity.java

他们产生相同的行为。

日志时全屏失败开放后恢复到正常的权利:当全屏成功

07-14 17:41:06.694 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 0 
07-14 17:41:06.786 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 1 
07-14 17:41:06.803 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:07.512 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 0 
07-14 17:41:07.592 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 1 
07-14 17:41:07.615 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:07.709 V/InputMethodManager: Starting input: [email protected] nm : com.linkhubapp ic=null 
07-14 17:41:07.709 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 
07-14 17:41:07.713 D/InputTransport: Input channel constructed: fd=152 
07-14 17:41:07.714 D/InputTransport: Input channel destroyed: fd=159 
07-14 17:41:07.714 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:07.751 D/[email protected][GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1176543232} surfaceGenerationChanged=false 
07-14 17:41:07.911 D/[email protected][GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x7 surface={isValid=true -1273339904} surfaceGenerationChanged=true 
07-14 17:41:07.921 D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1440x2560]-format:1 
07-14 17:41:07.922 D/[email protected][GroupActivity]: mHardwareRenderer.updateSurface() mSurface={isValid=true -1273339904} 
07-14 17:41:07.974 D/SurfaceView: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,875][1440,1685] result=0x7 surface={Surface(name=null)/@0xb9ffb70 isValid=true -1178691584} 
07-14 17:41:08.047 D/SurfaceView: Relayout returned: oldFrame=[0,875][1440,1685] newFrame=[0,875][1440,1685] result=0x5 surface={Surface(name=null)/@0xb9ffb70 isValid=false 0} 
07-14 17:41:08.095 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:08.163 D/[email protected][GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false 
07-14 17:41:08.232 V/InputMethodManager: Starting input: [email protected] nm : com.linkhubapp ic=null 
07-14 17:41:08.232 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 
07-14 17:41:08.233 D/InputTransport: Input channel constructed: fd=173 
07-14 17:41:08.233 D/InputTransport: Input channel destroyed: fd=152 

日志:

07-14 17:41:27.987 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 0 
07-14 17:41:28.023 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 1 
07-14 17:41:28.048 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:28.496 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 0 
07-14 17:41:28.571 D/[email protected][GroupActivity]: ViewPostImeInputStage processPointer 1 
07-14 17:41:28.616 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:28.719 V/InputMethodManager: Starting input: [email protected] nm : com.linkhubapp ic=null 
07-14 17:41:28.719 I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus 
07-14 17:41:28.725 D/InputTransport: Input channel constructed: fd=155 
07-14 17:41:28.725 D/InputTransport: Input channel destroyed: fd=173 
07-14 17:41:28.725 D/InputMethodManager: HSI from window - flag : 0 Pid : 6392 
07-14 17:41:28.766 D/[email protected][GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false 
07-14 17:41:28.956 D/[email protected][GroupActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x1 surface={isValid=true -1273339904} surfaceGenerationChanged=false 
07-14 17:41:29.036 D/SurfaceView: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,875][1440,1685] result=0x7 surface={Surface(name=null)/@0xc360d2 isValid=true -1273337856} 
07-14 17:41:29.089 D/SurfaceView: Relayout returned: oldFrame=[0,875][1440,1685] newFrame=[0,875][1440,1685] result=0x1 surface={Surface(name=null)/@0xc360d2 isValid=true -1311279104} 

编辑: 这似乎是在YouTube上只发生。测试Vimeo与YouTube。 Vimeo每次打开。

+0

它发生在特定设备上还是尝试过其他设备? –

+0

现在它只在三星Galaxy S6上测试过。我试着在明天做一些测试。 – CantThinkOfAnything

+0

相关:https://stackoverflow.com/questions/15768837/playing-html5-video-on-fullscreen-in-android-webview –

回答

1

我能想到的最好的事情就是你的设备没有内存。所以我有一些建议给你。

  • 首先,当您的设备上的所有内存都空闲并检查结果时,请在设备上进行测试。

  • 其次,你提到你有一个Galaxy S6和一个Galaxy S3,在两个设备上运行你的应用程序。

  • 此外,如果您可以在另一个Galaxy S6上测试您的应用程序并查看它是否重复,则它非常有帮助。

收集这些信息后,您可能能够找到解决问题的方法。

你可以测试的另一件事是使用android:hardwareAccelerated="true"并检查它是否有帮助。

+0

在S3,S6和S7上的行为是相同的。 “android:hardwareAccelerated =”true“”我已经设置好了。 – CantThinkOfAnything

1

这不直接回答你的问题,但提供了一个替代方案。

根据您的使用情况,将视频显示在YouTube应用程序中而不是在WebView内可能是可以接受的。 大多数Android设备(如果不是全部)都安装了YouTube应用程序。

public void playVideo(String key){ 

    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:" + key)); 

    // Check if the youtube app exists on the device 
    if (intent.resolveActivity(getPackageManager()) == null) { 
     // If the youtube app doesn't exist, then use the browser 
     intent = new Intent(Intent.ACTION_VIEW, 
       Uri.parse("http://www.youtube.com/watch?v=" + key)); 
    } else { 
     startActivity(intent); 
    } 
} 

它将要求用户点击“返回”以后返回到您的应用程序。 但它可能会给用户带来更好的视频体验。

+0

是的,我知道我可以通过YouTube的应用程序打开它,但它不符合这个项目的要求。无论如何thnx – CantThinkOfAnything

1

在我们与@CantThinkOfAnything讨论过程中,我们发现了确切的问题,并提出了解决方案。看起来这是三星手机的内部问题。他们有自己的WebView实现,它与Chrome WebView的某些细节和方法有所不同。努力克服与三星设备的网页视图问题之前(话说克服 - 我的意思是用另一种方法,而不是web视图)尝试:什么样的WebView实现您正在使用开发

  • 更新您的Web视图
  • 检查选项 - > WebView的实施在这里,你可以切换它

在这种情况下,我们只有在播放YouTube视频时遇到问题。因此,只要使用YouTube SDK之前,你可以尝试建立自己的球员:

<iframe width="300" height=".." src="http://www.youtube.com/embed/M68lNfqmTNk" frameborder="0" allowfullscreen></iframe> 

您将需要加载这个作为一个独立的HTML到您的网页流量。这是一种肮脏的方法,并有很多缺点。可能你不应该用这个。所以我们结束了使用Youtube SDK的解决方案,这比iframe好得多。 @CantThinkOfAnything - 请纠正我,如果我错过了什么。

P.S. - 在其他情况下,三星webview适合我们。

+0

你走了。谢谢! :d – CantThinkOfAnything

相关问题