Merge changes Ia44d880a,Ifbf63b24 into honeycomb-mr1
* changes: DO NOT MERGE : cherry pick of change Ieb7ae26b from master DO NOT MERGE : cherry pick of change I0f9f2c65 from master
This commit is contained in:
@ -191,8 +191,6 @@ public class HTML5VideoFullScreen extends HTML5VideoView
|
|||||||
|
|
||||||
if (mProgressView != null) {
|
if (mProgressView != null) {
|
||||||
mProgressView.setVisibility(View.GONE);
|
mProgressView.setVisibility(View.GONE);
|
||||||
mLayout.removeView(mProgressView);
|
|
||||||
mProgressView = null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mVideoWidth = mp.getVideoWidth();
|
mVideoWidth = mp.getVideoWidth();
|
||||||
@ -314,4 +312,13 @@ public class HTML5VideoFullScreen extends HTML5VideoView
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void switchProgressView(boolean playerBuffering) {
|
||||||
|
if (playerBuffering) {
|
||||||
|
mProgressView.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
|
mProgressView.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ import java.util.TimerTask;
|
|||||||
/**
|
/**
|
||||||
* @hide This is only used by the browser
|
* @hide This is only used by the browser
|
||||||
*/
|
*/
|
||||||
public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
|
public class HTML5VideoView implements MediaPlayer.OnPreparedListener {
|
||||||
|
|
||||||
protected static final String LOGTAG = "HTML5VideoView";
|
protected static final String LOGTAG = "HTML5VideoView";
|
||||||
|
|
||||||
@ -78,6 +78,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
|
|||||||
TIMEUPDATE_PERIOD);
|
TIMEUPDATE_PERIOD);
|
||||||
}
|
}
|
||||||
mPlayer.start();
|
mPlayer.start();
|
||||||
|
setPlayerBuffering(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +190,10 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
|
|||||||
mPlayer.setOnPreparedListener(this);
|
mPlayer.setOnPreparedListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setOnInfoListener(HTML5VideoViewProxy proxy) {
|
||||||
|
mPlayer.setOnInfoListener(proxy);
|
||||||
|
}
|
||||||
|
|
||||||
// Normally called immediately after setVideoURI. But for full screen,
|
// Normally called immediately after setVideoURI. But for full screen,
|
||||||
// this should be after surface holder created
|
// this should be after surface holder created
|
||||||
public void prepareDataAndDisplayMode(HTML5VideoViewProxy proxy) {
|
public void prepareDataAndDisplayMode(HTML5VideoViewProxy proxy) {
|
||||||
@ -198,7 +203,7 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
|
|||||||
setOnCompletionListener(proxy);
|
setOnCompletionListener(proxy);
|
||||||
setOnPreparedListener(proxy);
|
setOnPreparedListener(proxy);
|
||||||
setOnErrorListener(proxy);
|
setOnErrorListener(proxy);
|
||||||
|
setOnInfoListener(proxy);
|
||||||
// When there is exception, we could just bail out silently.
|
// When there is exception, we could just bail out silently.
|
||||||
// No Video will be played though. Write the stack for debug
|
// No Video will be played though. Write the stack for debug
|
||||||
try {
|
try {
|
||||||
@ -292,4 +297,21 @@ public class HTML5VideoView implements MediaPlayer.OnPreparedListener{
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This is true only when the player is buffering and paused
|
||||||
|
public boolean mPlayerBuffering = false;
|
||||||
|
|
||||||
|
public boolean getPlayerBuffering() {
|
||||||
|
return mPlayerBuffering;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPlayerBuffering(boolean playerBuffering) {
|
||||||
|
mPlayerBuffering = playerBuffering;
|
||||||
|
switchProgressView(playerBuffering);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void switchProgressView(boolean playerBuffering) {
|
||||||
|
// Only used in HTML5VideoFullScreen
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
implements MediaPlayer.OnPreparedListener,
|
implements MediaPlayer.OnPreparedListener,
|
||||||
MediaPlayer.OnCompletionListener,
|
MediaPlayer.OnCompletionListener,
|
||||||
MediaPlayer.OnErrorListener,
|
MediaPlayer.OnErrorListener,
|
||||||
|
MediaPlayer.OnInfoListener,
|
||||||
SurfaceTexture.OnFrameAvailableListener {
|
SurfaceTexture.OnFrameAvailableListener {
|
||||||
// Logging tag.
|
// Logging tag.
|
||||||
private static final String LOGTAG = "HTML5VideoViewProxy";
|
private static final String LOGTAG = "HTML5VideoViewProxy";
|
||||||
@ -56,6 +57,8 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
private static final int PAUSE = 102;
|
private static final int PAUSE = 102;
|
||||||
private static final int ERROR = 103;
|
private static final int ERROR = 103;
|
||||||
private static final int LOAD_DEFAULT_POSTER = 104;
|
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
|
// Message Ids to be handled on the WebCore thread
|
||||||
private static final int PREPARED = 200;
|
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.
|
// identify the exact layer on the UI thread to use the SurfaceTexture.
|
||||||
private static int mBaseLayer = 0;
|
private static int mBaseLayer = 0;
|
||||||
|
|
||||||
|
private static void setPlayerBuffering(boolean playerBuffering) {
|
||||||
|
mHTML5VideoView.setPlayerBuffering(playerBuffering);
|
||||||
|
}
|
||||||
|
|
||||||
// Every time webView setBaseLayer, this will be called.
|
// Every time webView setBaseLayer, this will be called.
|
||||||
// When we found the Video layer, then we set the Surface Texture to it.
|
// 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.
|
// Otherwise, we may want to delete the Surface Texture to save memory.
|
||||||
@ -106,6 +113,8 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
int currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
|
int currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
|
||||||
if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) {
|
if (layer != 0 && surfTexture != null && currentVideoLayerId != -1) {
|
||||||
int playerState = mHTML5VideoView.getCurrentState();
|
int playerState = mHTML5VideoView.getCurrentState();
|
||||||
|
if (mHTML5VideoView.getPlayerBuffering())
|
||||||
|
playerState = HTML5VideoView.STATE_NOTPREPARED;
|
||||||
boolean foundInTree = nativeSendSurfaceTexture(surfTexture,
|
boolean foundInTree = nativeSendSurfaceTexture(surfTexture,
|
||||||
layer, currentVideoLayerId, textureName,
|
layer, currentVideoLayerId, textureName,
|
||||||
playerState);
|
playerState);
|
||||||
@ -159,7 +168,6 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
WebChromeClient client, int videoLayerId) {
|
WebChromeClient client, int videoLayerId) {
|
||||||
int currentVideoLayerId = -1;
|
int currentVideoLayerId = -1;
|
||||||
boolean backFromFullScreenMode = false;
|
boolean backFromFullScreenMode = false;
|
||||||
|
|
||||||
if (mHTML5VideoView != null) {
|
if (mHTML5VideoView != null) {
|
||||||
currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
|
currentVideoLayerId = mHTML5VideoView.getVideoLayerId();
|
||||||
if (mHTML5VideoView instanceof HTML5VideoFullScreen) {
|
if (mHTML5VideoView instanceof HTML5VideoFullScreen) {
|
||||||
@ -342,6 +350,14 @@ class HTML5VideoViewProxy extends Handler
|
|||||||
}
|
}
|
||||||
break;
|
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,
|
private native static boolean nativeSendSurfaceTexture(SurfaceTexture texture,
|
||||||
int baseLayer, int videoLayerId, int textureName,
|
int baseLayer, int videoLayerId, int textureName,
|
||||||
int playerState);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user