From a9cadefde4d5f79a0f3ed093bb96d9c919ce65c3 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Tue, 29 Mar 2011 10:35:11 -0700 Subject: DO NOT MERGE : cherry pick of change I0f9f2c65 from master Add the loading progress UI when buffering bug:4187252 Change-Id: Ifbf63b248ac5f0e340be4057e0dcd80d33483662 --- core/java/android/webkit/HTML5VideoViewProxy.java | 28 ++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'core/java/android/webkit/HTML5VideoViewProxy.java') diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java index c7270299bec0..18c5ec6b282e 100644 --- a/core/java/android/webkit/HTML5VideoViewProxy.java +++ b/core/java/android/webkit/HTML5VideoViewProxy.java @@ -46,6 +46,7 @@ class HTML5VideoViewProxy extends Handler implements MediaPlayer.OnPreparedListener, MediaPlayer.OnCompletionListener, MediaPlayer.OnErrorListener, + MediaPlayer.OnInfoListener, SurfaceTexture.OnFrameAvailableListener { // Logging tag. private static final String LOGTAG = "HTML5VideoViewProxy"; @@ -56,6 +57,8 @@ class HTML5VideoViewProxy extends Handler private static final int PAUSE = 102; private static final int ERROR = 103; private static final int LOAD_DEFAULT_POSTER = 104; + private static final int BUFFERING_START = 105; + private static final int BUFFERING_END = 106; // Message Ids to be handled on the WebCore thread private static final int PREPARED = 200; @@ -92,6 +95,8 @@ class HTML5VideoViewProxy extends Handler // identify the exact layer on the UI thread to use the SurfaceTexture. private static int mBaseLayer = 0; + // This is true only when the player is buffering and paused + private static boolean mPlayerBuffering = false; // Every time webView setBaseLayer, this will be called. // When we found the Video layer, then we set the Surface Texture to it. // Otherwise, we may want to delete the Surface Texture to save memory. @@ -106,6 +111,8 @@ class HTML5VideoViewProxy extends Handler int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { int playerState = mHTML5VideoView.getCurrentState(); + if (mPlayerBuffering) + playerState = HTML5VideoView.STATE_NOTPREPARED; boolean foundInTree = nativeSendSurfaceTexture(surfTexture, layer, currentVideoLayerId, textureName, playerState); @@ -159,7 +166,7 @@ class HTML5VideoViewProxy extends Handler WebChromeClient client, int videoLayerId) { int currentVideoLayerId = -1; boolean backFromFullScreenMode = false; - + mPlayerBuffering = false; if (mHTML5VideoView != null) { currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (mHTML5VideoView instanceof HTML5VideoFullScreen) { @@ -224,6 +231,7 @@ class HTML5VideoViewProxy extends Handler } public static void onPrepared() { + mPlayerBuffering = false; if (!mHTML5VideoView.isFullScreenMode() || mHTML5VideoView.getAutostart()) { mHTML5VideoView.start(); } @@ -342,6 +350,14 @@ class HTML5VideoViewProxy extends Handler } break; } + case BUFFERING_START: { + VideoPlayer.mPlayerBuffering = true; + break; + } + case BUFFERING_END: { + VideoPlayer.mPlayerBuffering = false; + break; + } } } @@ -671,4 +687,14 @@ class HTML5VideoViewProxy extends Handler private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture, int baseLayer, int videoLayerId, int textureName, int playerState); + + @Override + public boolean onInfo(MediaPlayer mp, int what, int extra) { + if (what == MediaPlayer.MEDIA_INFO_BUFFERING_START) { + sendMessage(obtainMessage(BUFFERING_START, what, extra)); + } else if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END) { + sendMessage(obtainMessage(BUFFERING_END, what, extra)); + } + return false; + } } -- cgit v1.2.3 From 2fcf82aee30da977849adaaadf89d81c17afbac2 Mon Sep 17 00:00:00 2001 From: Teng-Hui Zhu Date: Wed, 30 Mar 2011 14:39:56 -0700 Subject: DO NOT MERGE : cherry pick of change Ieb7ae26b from master Buffering in full screen mode will show progressView bug:4187252 Change-Id: Ia44d880ab126c2439fb13504db87492d45c90bc8 --- core/java/android/webkit/HTML5VideoViewProxy.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'core/java/android/webkit/HTML5VideoViewProxy.java') diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java index 18c5ec6b282e..060c0bbfdde9 100644 --- a/core/java/android/webkit/HTML5VideoViewProxy.java +++ b/core/java/android/webkit/HTML5VideoViewProxy.java @@ -95,8 +95,10 @@ class HTML5VideoViewProxy extends Handler // identify the exact layer on the UI thread to use the SurfaceTexture. private static int mBaseLayer = 0; - // This is true only when the player is buffering and paused - private static boolean mPlayerBuffering = false; + private static void setPlayerBuffering(boolean playerBuffering) { + mHTML5VideoView.setPlayerBuffering(playerBuffering); + } + // Every time webView setBaseLayer, this will be called. // When we found the Video layer, then we set the Surface Texture to it. // Otherwise, we may want to delete the Surface Texture to save memory. @@ -111,7 +113,7 @@ class HTML5VideoViewProxy extends Handler int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { int playerState = mHTML5VideoView.getCurrentState(); - if (mPlayerBuffering) + if (mHTML5VideoView.getPlayerBuffering()) playerState = HTML5VideoView.STATE_NOTPREPARED; boolean foundInTree = nativeSendSurfaceTexture(surfTexture, layer, currentVideoLayerId, textureName, @@ -166,7 +168,6 @@ class HTML5VideoViewProxy extends Handler WebChromeClient client, int videoLayerId) { int currentVideoLayerId = -1; boolean backFromFullScreenMode = false; - mPlayerBuffering = false; if (mHTML5VideoView != null) { currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (mHTML5VideoView instanceof HTML5VideoFullScreen) { @@ -231,7 +232,6 @@ class HTML5VideoViewProxy extends Handler } public static void onPrepared() { - mPlayerBuffering = false; if (!mHTML5VideoView.isFullScreenMode() || mHTML5VideoView.getAutostart()) { mHTML5VideoView.start(); } @@ -351,11 +351,11 @@ class HTML5VideoViewProxy extends Handler break; } case BUFFERING_START: { - VideoPlayer.mPlayerBuffering = true; + VideoPlayer.setPlayerBuffering(true); break; } case BUFFERING_END: { - VideoPlayer.mPlayerBuffering = false; + VideoPlayer.setPlayerBuffering(false); break; } } -- cgit v1.2.3