| 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..b17512b599940166e220fe7b3d58f62ac60314c8 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_this_(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_this_.GetWeakPtr()));
|
| }
|
|
|
| ScopedJavaLocalRef<jobject> ContentVideoView::GetJavaObject(JNIEnv* env) {
|
|
|