Commit 3b7f0ac7 authored by shouqun@chromium.org's avatar shouqun@chromium.org

[Android] Fix the issue of muted attribute in video element does not work.

SetVolume is called before the media player bridge is created, so the
volume(muted) is not set correctly.

BUG=377737

Review URL: https://codereview.chromium.org/296393007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@273160 0039d316-1c4b-4281-b951-d872f2087c98
parent fae16daa
......@@ -50,6 +50,7 @@ MediaPlayerBridge::MediaPlayerBridge(
can_seek_forward_(true),
can_seek_backward_(true),
is_surface_in_use_(false),
volume_(-1.0),
weak_factory_(this) {
listener_.reset(new MediaPlayerListener(base::MessageLoopProxy::current(),
weak_factory_.GetWeakPtr()));
......@@ -94,6 +95,9 @@ void MediaPlayerBridge::CreateJavaMediaPlayerBridge() {
j_media_player_bridge_.Reset(Java_MediaPlayerBridge_create(
env, reinterpret_cast<intptr_t>(this)));
if (volume_ >= 0)
SetVolume(volume_);
SetMediaPlayerListener();
}
......@@ -323,8 +327,10 @@ void MediaPlayerBridge::Release() {
}
void MediaPlayerBridge::SetVolume(double volume) {
if (j_media_player_bridge_.is_null())
if (j_media_player_bridge_.is_null()) {
volume_ = volume;
return;
}
JNIEnv* env = base::android::AttachCurrentThread();
CHECK(env);
......
......@@ -176,6 +176,9 @@ class MEDIA_EXPORT MediaPlayerBridge : public MediaPlayerAndroid {
// Whether player is currently using a surface.
bool is_surface_in_use_;
// Volume of playback.
double volume_;
// Weak pointer passed to |listener_| for callbacks.
// NOTE: Weak pointers must be invalidated before all other member variables.
base::WeakPtrFactory<MediaPlayerBridge> weak_factory_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment