Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(571)

Unified Diff: content/browser/android/content_video_view.cc

Issue 141243002: Fix an issue that MediaController is disaled when entering fullscreen (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/android/content_video_view.cc
diff --git a/content/browser/android/content_video_view.cc b/content/browser/android/content_video_view.cc
index 85f5719954fd4d50f77f1e02d70a0a408959ef5c..af3067a2094b4d2dc014125e7bd987948fa25dd1 100644
--- a/content/browser/android/content_video_view.cc
+++ b/content/browser/android/content_video_view.cc
@@ -6,6 +6,7 @@
#include "base/command_line.h"
#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
#include "content/browser/android/content_view_core_impl.h"
#include "content/browser/media/android/browser_media_player_manager.h"
#include "content/common/android/surface_texture_peer.h"
@@ -43,7 +44,8 @@ ContentVideoView* ContentVideoView::GetInstance() {
ContentVideoView::ContentVideoView(
BrowserMediaPlayerManager* manager)
: manager_(manager),
- fullscreen_state_(ENTERED) {
+ fullscreen_state_(ENTERED),
+ weak_factory_(this) {
DCHECK(!g_content_video_view);
j_content_video_view_ = CreateJavaObject();
g_content_video_view = this;
@@ -108,8 +110,16 @@ void ContentVideoView::OnExitFullscreen() {
void ContentVideoView::UpdateMediaMetadata() {
JNIEnv *env = AttachCurrentThread();
ScopedJavaLocalRef<jobject> content_video_view = GetJavaObject(env);
- if (!content_video_view.is_null())
- UpdateMediaMetadata(env, content_video_view.obj());
+ if (content_video_view.is_null())
+ return;
+
+ media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer();
+ if (player && player->IsPlayerReady()) {
+ Java_ContentVideoView_onUpdateMediaMetadata(
+ env, content_video_view.obj(), player->GetVideoWidth(),
+ player->GetVideoHeight(), player->GetDuration().InMilliseconds(),
+ player->CanPause(),player->CanSeekForward(), player->CanSeekBackward());
+ }
}
int ContentVideoView::GetVideoWidth(JNIEnv*, jobject obj) const {
@@ -187,13 +197,11 @@ void ContentVideoView::SetSurface(JNIEnv* env, jobject obj,
}
}
-void ContentVideoView::UpdateMediaMetadata(JNIEnv* env, jobject obj) {
- media::MediaPlayerAndroid* player = manager_->GetFullscreenPlayer();
- if (player && player->IsPlayerReady())
- Java_ContentVideoView_onUpdateMediaMetadata(
- env, obj, player->GetVideoWidth(), player->GetVideoHeight(),
- player->GetDuration().InMilliseconds(), player->CanPause(),
- player->CanSeekForward(), player->CanSeekBackward());
+void ContentVideoView::RequestMediaMetadata(JNIEnv* env, jobject obj) {
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE,
+ base::Bind(&ContentVideoView::UpdateMediaMetadata,
+ weak_factory_.GetWeakPtr()));
}
ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) {

Powered by Google App Engine
This is Rietveld 408576698