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

Commit

Permalink
Skip initial seek to 0 on fling
Browse files Browse the repository at this point in the history
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}
  • Loading branch information
dgn authored and Commit bot committed Oct 21, 2014
1 parent b228d03 commit 43dd925
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions media/base/android/media_player_bridge.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ MediaPlayerBridge::MediaPlayerBridge(
frame_url),
prepared_(false),
pending_play_(false),
should_seek_on_prepare_(false),
url_(url),
first_party_for_cookies_(first_party_for_cookies),
user_agent_(user_agent),
Expand Down Expand Up @@ -338,6 +339,7 @@ int MediaPlayerBridge::GetVideoHeight() {
void MediaPlayerBridge::SeekTo(base::TimeDelta timestamp) {
// Record the time to seek when OnMediaPrepared() is called.
pending_seek_ = timestamp;
should_seek_on_prepare_ = true;

if (j_media_player_bridge_.is_null())
Prepare();
Expand Down Expand Up @@ -369,8 +371,11 @@ void MediaPlayerBridge::Release() {
return;

time_update_timer_.Stop();
if (prepared_)
if (prepared_) {
pending_seek_ = GetCurrentTime();
should_seek_on_prepare_ = true;
}

prepared_ = false;
pending_play_ = false;
SetVideoSurface(gfx::ScopedJavaSurface());
Expand Down Expand Up @@ -417,7 +422,11 @@ void MediaPlayerBridge::OnMediaPrepared() {

// If media player was recovered from a saved state, consume all the pending
// events.
PendingSeekInternal(pending_seek_);
if (should_seek_on_prepare_) {
PendingSeekInternal(pending_seek_);
pending_seek_ = base::TimeDelta::FromMilliseconds(0);
should_seek_on_prepare_ = false;
}

if (pending_play_) {
StartInternal();
Expand Down
3 changes: 3 additions & 0 deletions media/base/android/media_player_bridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ class MEDIA_EXPORT MediaPlayerBridge : public MediaPlayerAndroid {
// Pending seek time while player is preparing.
base::TimeDelta pending_seek_;

// Whether a seek should be performed after preparing.
bool should_seek_on_prepare_;

// Url for playback.
GURL url_;

Expand Down

0 comments on commit 43dd925

Please sign in to comment.