Skip to content
This repository was archived by the owner on Apr 3, 2020. It is now read-only.

Commit 43dd925

Browse files
dgnCommit bot
dgn
authored and
Commit bot
committed
Skip initial seek to 0 on fling
The media player now won't seek after load when there is no actual pending seek. BUG=420645 Review URL: https://codereview.chromium.org/654203005 Cr-Commit-Position: refs/heads/master@{#300452}
1 parent b228d03 commit 43dd925

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

media/base/android/media_player_bridge.cc

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ MediaPlayerBridge::MediaPlayerBridge(
3838
frame_url),
3939
prepared_(false),
4040
pending_play_(false),
41+
should_seek_on_prepare_(false),
4142
url_(url),
4243
first_party_for_cookies_(first_party_for_cookies),
4344
user_agent_(user_agent),
@@ -338,6 +339,7 @@ int MediaPlayerBridge::GetVideoHeight() {
338339
void MediaPlayerBridge::SeekTo(base::TimeDelta timestamp) {
339340
// Record the time to seek when OnMediaPrepared() is called.
340341
pending_seek_ = timestamp;
342+
should_seek_on_prepare_ = true;
341343

342344
if (j_media_player_bridge_.is_null())
343345
Prepare();
@@ -369,8 +371,11 @@ void MediaPlayerBridge::Release() {
369371
return;
370372

371373
time_update_timer_.Stop();
372-
if (prepared_)
374+
if (prepared_) {
373375
pending_seek_ = GetCurrentTime();
376+
should_seek_on_prepare_ = true;
377+
}
378+
374379
prepared_ = false;
375380
pending_play_ = false;
376381
SetVideoSurface(gfx::ScopedJavaSurface());
@@ -417,7 +422,11 @@ void MediaPlayerBridge::OnMediaPrepared() {
417422

418423
// If media player was recovered from a saved state, consume all the pending
419424
// events.
420-
PendingSeekInternal(pending_seek_);
425+
if (should_seek_on_prepare_) {
426+
PendingSeekInternal(pending_seek_);
427+
pending_seek_ = base::TimeDelta::FromMilliseconds(0);
428+
should_seek_on_prepare_ = false;
429+
}
421430

422431
if (pending_play_) {
423432
StartInternal();

media/base/android/media_player_bridge.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ class MEDIA_EXPORT MediaPlayerBridge : public MediaPlayerAndroid {
144144
// Pending seek time while player is preparing.
145145
base::TimeDelta pending_seek_;
146146

147+
// Whether a seek should be performed after preparing.
148+
bool should_seek_on_prepare_;
149+
147150
// Url for playback.
148151
GURL url_;
149152

0 commit comments

Comments
 (0)