summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorChong Zhang <chz@google.com>2015-05-06 13:14:59 -0700
committerChong Zhang <chz@google.com>2015-05-07 22:43:27 +0000
commit1e6be7285d4dc8b494c70aef8d2ed8b8c1d8e0de (patch)
tree2b3dea8a401ea44723d0fdf40a306139a0b64667 /media
parentc1125dedfcb52644aabc175d749c89b3008e4337 (diff)
downloadframeworks_base-1e6be7285d4dc8b494c70aef8d2ed8b8c1d8e0de.zip
frameworks_base-1e6be7285d4dc8b494c70aef8d2ed8b8c1d8e0de.tar.gz
frameworks_base-1e6be7285d4dc8b494c70aef8d2ed8b8c1d8e0de.tar.bz2
MediaPlayer: pause media time when buffering
bug: 20500732 Change-Id: Ife7f75f5cc587af56451c85ea8adbdc380f38348
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/MediaPlayer.java21
1 files changed, 20 insertions, 1 deletions
diff --git a/media/java/android/media/MediaPlayer.java b/media/java/android/media/MediaPlayer.java
index 6ec10c7..b3c1b4d 100644
--- a/media/java/android/media/MediaPlayer.java
+++ b/media/java/android/media/MediaPlayer.java
@@ -2824,6 +2824,13 @@ public class MediaPlayer implements SubtitleController.Listener
mSubtitleController.selectDefaultTrack();
}
break;
+ case MEDIA_INFO_BUFFERING_START:
+ case MEDIA_INFO_BUFFERING_END:
+ TimeProvider timeProvider = mTimeProvider;
+ if (timeProvider != null) {
+ timeProvider.onBuffering(msg.arg1 == MEDIA_INFO_BUFFERING_START);
+ }
+ break;
}
if (mOnInfoListener != null) {
@@ -3362,6 +3369,7 @@ public class MediaPlayer implements SubtitleController.Listener
private MediaPlayer mPlayer;
private boolean mPaused = true;
private boolean mStopped = true;
+ private boolean mBuffering;
private long mLastReportedTime;
private long mTimeAdjustment;
// since we are expecting only a handful listeners per stream, there is
@@ -3455,12 +3463,22 @@ public class MediaPlayer implements SubtitleController.Listener
}
/** @hide */
+ public void onBuffering(boolean buffering) {
+ synchronized (this) {
+ if (DEBUG) Log.d(TAG, "onBuffering: " + buffering);
+ mBuffering = buffering;
+ scheduleNotification(REFRESH_AND_NOTIFY_TIME, 0 /* delay */);
+ }
+ }
+
+ /** @hide */
public void onStopped() {
synchronized(this) {
if (DEBUG) Log.d(TAG, "onStopped");
mPaused = true;
mStopped = true;
mSeeking = false;
+ mBuffering = false;
scheduleNotification(NOTIFY_STOP, 0 /* delay */);
}
}
@@ -3481,6 +3499,7 @@ public class MediaPlayer implements SubtitleController.Listener
synchronized(this) {
mStopped = false;
mSeeking = true;
+ mBuffering = false;
scheduleNotification(NOTIFY_SEEK, 0 /* delay */);
}
}
@@ -3683,7 +3702,7 @@ public class MediaPlayer implements SubtitleController.Listener
nanoTime >= mLastNanoTime + MAX_NS_WITHOUT_POSITION_CHECK) {
try {
mLastTimeUs = mPlayer.getCurrentPosition() * 1000L;
- mPaused = !mPlayer.isPlaying();
+ mPaused = !mPlayer.isPlaying() || mBuffering;
if (DEBUG) Log.v(TAG, (mPaused ? "paused" : "playing") + " at " + mLastTimeUs);
} catch (IllegalStateException e) {
if (mPausing) {