Tear down ContentVideoView from content-layer
Background: ContentVideoView displays fullscreen video in a
VideoViewSurface. Currently, each Android content embedder
(WebView, ContentShell, and ChromeShell) is responsible for
releasing this surface when exiting fullscreen.
Problem: Releasing ContentVideoView from each embedder leads to
code duplication. Worse, this was never done for the WebView:
when it exits fullscreen video playback, AwContents's
exitFullScreen removes the VideoViewSurface which triggers
ContentVideoView's surfaceDestroyed(). surfaceDestroyed()
releases the MediaPlayerAndroid. Releasing the MediaPlayerAndroid
during playback gives a frozen video (see bug).
Solution: For all content embedders on Android, tear down
ContentVideoView, from content-layer (before the embedder
specific "exit fullscreen"-work).
BUG=449152
TEST=For unencrypted video, manually verify that video playback
continues inline when exiting fullscreen (tested in
com.android.browser, ContentShell and ChromeShell). Added
automatic test for VIDEO_HOLE-playback in WebView.
Review URL: https://codereview.chromium.org/845193005
Cr-Commit-Position: refs/heads/master@{#313531}
diff --git a/content/browser/web_contents/web_contents_impl.cc b/content/browser/web_contents/web_contents_impl.cc
index 0ad2f31..9d11bbb5 100644
--- a/content/browser/web_contents/web_contents_impl.cc
+++ b/content/browser/web_contents/web_contents_impl.cc
@@ -108,6 +108,7 @@
#endif
#if defined(OS_ANDROID)
+#include "content/browser/android/content_video_view.h"
#include "content/browser/android/date_time_chooser_android.h"
#include "content/browser/media/android/browser_media_player_manager.h"
#include "content/browser/web_contents/web_contents_android.h"
@@ -1485,6 +1486,12 @@
if (widget_view)
RenderWidgetHostImpl::From(widget_view->GetRenderWidgetHost())->Shutdown();
+#if defined(OS_ANDROID)
+ ContentVideoView* video_view = ContentVideoView::GetInstance();
+ if (video_view != NULL)
+ video_view->OnExitFullscreen();
+#endif
+
if (delegate_)
delegate_->ExitFullscreenModeForTab(this);