am f0afad00: Merge "Stop caching stream duration, it might change (increase) dynamically." into jb-mr1.1-dev
* commit 'f0afad008bf78576ff364bcd8bc93b7aa8090b34': Stop caching stream duration, it might change (increase) dynamically.
This commit is contained in:
@@ -54,7 +54,6 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
|
|||||||
// settable by the client
|
// settable by the client
|
||||||
private Uri mUri;
|
private Uri mUri;
|
||||||
private Map<String, String> mHeaders;
|
private Map<String, String> mHeaders;
|
||||||
private int mDuration;
|
|
||||||
|
|
||||||
// all possible internal states
|
// all possible internal states
|
||||||
private static final int STATE_ERROR = -1;
|
private static final int STATE_ERROR = -1;
|
||||||
@@ -229,7 +228,6 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
|
|||||||
mMediaPlayer = new MediaPlayer();
|
mMediaPlayer = new MediaPlayer();
|
||||||
mMediaPlayer.setOnPreparedListener(mPreparedListener);
|
mMediaPlayer.setOnPreparedListener(mPreparedListener);
|
||||||
mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
|
mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
|
||||||
mDuration = -1;
|
|
||||||
mMediaPlayer.setOnCompletionListener(mCompletionListener);
|
mMediaPlayer.setOnCompletionListener(mCompletionListener);
|
||||||
mMediaPlayer.setOnErrorListener(mErrorListener);
|
mMediaPlayer.setOnErrorListener(mErrorListener);
|
||||||
mMediaPlayer.setOnInfoListener(mOnInfoListener);
|
mMediaPlayer.setOnInfoListener(mOnInfoListener);
|
||||||
@@ -608,17 +606,12 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
|
|||||||
openVideo();
|
openVideo();
|
||||||
}
|
}
|
||||||
|
|
||||||
// cache duration as mDuration for faster access
|
|
||||||
public int getDuration() {
|
public int getDuration() {
|
||||||
if (isInPlaybackState()) {
|
if (isInPlaybackState()) {
|
||||||
if (mDuration > 0) {
|
return mMediaPlayer.getDuration();
|
||||||
return mDuration;
|
|
||||||
}
|
|
||||||
mDuration = mMediaPlayer.getDuration();
|
|
||||||
return mDuration;
|
|
||||||
}
|
}
|
||||||
mDuration = -1;
|
|
||||||
return mDuration;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getCurrentPosition() {
|
public int getCurrentPosition() {
|
||||||
|
|||||||
Reference in New Issue
Block a user