diff options
author | Teng-Hui Zhu <ztenghui@google.com> | 2011-04-07 14:22:33 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-04-07 14:22:33 -0700 |
commit | 29fa50be2484ed9d7a5e8075b764caa37b6494b9 (patch) | |
tree | c31232e45dfd65f13624973628ef278a718bad41 /core/java/android/webkit/HTML5VideoViewProxy.java | |
parent | 96ac85607b1462508981936b1be29ae5f9e4271d (diff) | |
parent | bb55777be1a3231d187205dc378ca35b01e8bc65 (diff) | |
download | frameworks_base-29fa50be2484ed9d7a5e8075b764caa37b6494b9.zip frameworks_base-29fa50be2484ed9d7a5e8075b764caa37b6494b9.tar.gz frameworks_base-29fa50be2484ed9d7a5e8075b764caa37b6494b9.tar.bz2 |
am bb55777b: Merge changes Ia44d880a,Ifbf63b24 into honeycomb-mr1
* commit 'bb55777be1a3231d187205dc378ca35b01e8bc65':
DO NOT MERGE : cherry pick of change Ieb7ae26b from master
DO NOT MERGE : cherry pick of change I0f9f2c65 from master
Diffstat (limited to 'core/java/android/webkit/HTML5VideoViewProxy.java')
-rw-r--r-- | core/java/android/webkit/HTML5VideoViewProxy.java | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/core/java/android/webkit/HTML5VideoViewProxy.java b/core/java/android/webkit/HTML5VideoViewProxy.java index c727029..060c0bb 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,10 @@ class HTML5VideoViewProxy extends Handler // identify the exact layer on the UI thread to use the SurfaceTexture. private static int mBaseLayer = 0; + 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. @@ -106,6 +113,8 @@ class HTML5VideoViewProxy extends Handler int currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) { int playerState = mHTML5VideoView.getCurrentState(); + if (mHTML5VideoView.getPlayerBuffering()) + playerState = HTML5VideoView.STATE_NOTPREPARED; boolean foundInTree = nativeSendSurfaceTexture(surfTexture, layer, currentVideoLayerId, textureName, playerState); @@ -159,7 +168,6 @@ class HTML5VideoViewProxy extends Handler WebChromeClient client, int videoLayerId) { int currentVideoLayerId = -1; boolean backFromFullScreenMode = false; - if (mHTML5VideoView != null) { currentVideoLayerId = mHTML5VideoView.getVideoLayerId(); if (mHTML5VideoView instanceof HTML5VideoFullScreen) { @@ -342,6 +350,14 @@ class HTML5VideoViewProxy extends Handler } break; } + case BUFFERING_START: { + VideoPlayer.setPlayerBuffering(true); + break; + } + case BUFFERING_END: { + VideoPlayer.setPlayerBuffering(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; + } } |