Skip to content

Commit 585c07e

Browse files
committed
Stop caching stream duration, it might change (increase) dynamically.
Change-Id: Ia829f47602e6961f24464da36a0162b8c1d7d6c8 related-to-bug: 6870049
1 parent f426ace commit 585c07e

File tree

1 file changed

+3
-10
lines changed

1 file changed

+3
-10
lines changed

core/java/android/widget/VideoView.java

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ public class VideoView extends SurfaceView implements MediaPlayerControl {
5454
// settable by the client
5555
private Uri mUri;
5656
private Map<String, String> mHeaders;
57-
private int mDuration;
5857

5958
// all possible internal states
6059
private static final int STATE_ERROR = -1;
@@ -229,7 +228,6 @@ private void openVideo() {
229228
mMediaPlayer = new MediaPlayer();
230229
mMediaPlayer.setOnPreparedListener(mPreparedListener);
231230
mMediaPlayer.setOnVideoSizeChangedListener(mSizeChangedListener);
232-
mDuration = -1;
233231
mMediaPlayer.setOnCompletionListener(mCompletionListener);
234232
mMediaPlayer.setOnErrorListener(mErrorListener);
235233
mMediaPlayer.setOnInfoListener(mOnInfoListener);
@@ -608,17 +606,12 @@ public void resume() {
608606
openVideo();
609607
}
610608

611-
// cache duration as mDuration for faster access
612609
public int getDuration() {
613610
if (isInPlaybackState()) {
614-
if (mDuration > 0) {
615-
return mDuration;
616-
}
617-
mDuration = mMediaPlayer.getDuration();
618-
return mDuration;
611+
return mMediaPlayer.getDuration();
619612
}
620-
mDuration = -1;
621-
return mDuration;
613+
614+
return -1;
622615
}
623616

624617
public int getCurrentPosition() {

0 commit comments

Comments
 (0)