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

Unified Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 1313613003: Fix a bug that current time can go backwards when playing a video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix the flakiness in test Created 5 years, 4 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/android/webmediaplayer_android.cc
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 81a8d6a9619923274d07e3a3664f42c4c49fb8ae..6f92c21f5293926c66afc0f568ebc778b2d89503 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -917,6 +917,10 @@ void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_timestamp,
base::TimeTicks current_time_ticks) {
DCHECK(main_thread_checker_.CalledOnValidThread());
+
+ if (seeking())
+ return;
+
// Compensate the current_timestamp with the IPC latency.
base::TimeDelta lower_bound =
base::TimeTicks::Now() - current_time_ticks + current_timestamp;
@@ -930,7 +934,9 @@ void WebMediaPlayerAndroid::OnTimeUpdate(base::TimeDelta current_timestamp,
// if the lower_bound is smaller than the current time, just use the current
// time so that the timer is always progressing.
lower_bound =
- std::min(lower_bound, base::TimeDelta::FromSecondsD(currentTime()));
+ std::max(lower_bound, base::TimeDelta::FromSecondsD(currentTime()));
+ if (lower_bound > upper_bound)
+ upper_bound = lower_bound;
interpolator_.SetBounds(lower_bound, upper_bound);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698