Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(955)

Unified Diff: media/base/android/media_player_bridge.cc

Issue 1234483003: Prevent seeking when Android MediaPlayer reports that it's not possible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments from qinmin. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/base/android/media_player_bridge.h ('k') | media/base/android/media_player_bridge_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/android/media_player_bridge.cc
diff --git a/media/base/android/media_player_bridge.cc b/media/base/android/media_player_bridge.cc
index ad95c53008cffcf013e2c69d017288d890d7eb79..573056e6d696435200635ba8ca2edafc3c87e235 100644
--- a/media/base/android/media_player_bridge.cc
+++ b/media/base/android/media_player_bridge.cc
@@ -328,7 +328,7 @@ void MediaPlayerBridge::SeekTo(base::TimeDelta timestamp) {
if (j_media_player_bridge_.is_null())
Prepare();
else if (prepared_)
- SeekInternal(timestamp);
+ SeekInternal(GetCurrentTime(), timestamp);
}
base::TimeDelta MediaPlayerBridge::GetCurrentTime() {
@@ -481,10 +481,19 @@ void MediaPlayerBridge::PauseInternal() {
}
void MediaPlayerBridge::PendingSeekInternal(const base::TimeDelta& time) {
- SeekInternal(time);
+ SeekInternal(GetCurrentTime(), time);
}
-void MediaPlayerBridge::SeekInternal(base::TimeDelta time) {
+bool MediaPlayerBridge::SeekInternal(base::TimeDelta current_time,
+ base::TimeDelta time) {
+ // Seeking on content like live streams may cause the media player to
+ // get stuck in an error state.
+ if (time < current_time && !CanSeekBackward())
+ return false;
+
+ if (time >= current_time && !CanSeekForward())
+ return false;
+
if (time > duration_)
time = duration_;
@@ -492,7 +501,7 @@ void MediaPlayerBridge::SeekInternal(base::TimeDelta time) {
// error state.
if (time < base::TimeDelta()) {
DCHECK_EQ(-1.0, time.InMillisecondsF());
- return;
+ return false;
}
JNIEnv* env = base::android::AttachCurrentThread();
@@ -500,6 +509,7 @@ void MediaPlayerBridge::SeekInternal(base::TimeDelta time) {
int time_msec = static_cast<int>(time.InMilliseconds());
Java_MediaPlayerBridge_seekTo(
env, j_media_player_bridge_.obj(), time_msec);
+ return true;
}
void MediaPlayerBridge::OnTimeUpdateTimerFired() {
« no previous file with comments | « media/base/android/media_player_bridge.h ('k') | media/base/android/media_player_bridge_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698