Chromium Code Reviews| Index: media/blink/webmediaplayer_impl.cc |
| diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc |
| index 986984dbcccfa5eb63212ecc399d087fab52c0bd..b1fefd2cc02a1adb48f40cda210fd302f3f4ebab 100644 |
| --- a/media/blink/webmediaplayer_impl.cc |
| +++ b/media/blink/webmediaplayer_impl.cc |
| @@ -348,8 +348,19 @@ void WebMediaPlayerImpl::play() { |
| media_log_->AddEvent(media_log_->CreateEvent(MediaLogEvent::PLAY)); |
| - if (playback_rate_ > 0) |
| - NotifyPlaybackStarted(); |
| + if (playback_rate_ > 0) { |
| + // Resume the player if playback was initiated in the foreground. Resume() |
| + // will do nothing if the pipeline is not suspended state, but will clear |
| + // some internal pending state, so it should always be called. |
| + const bool was_suspended = pipeline_controller_.IsSuspended(); |
| + if (delegate_ && !delegate_->IsHidden()) |
| + pipeline_controller_.Resume(); |
| + |
| + // If we were in the suspended state, OnPipelineResumed() will take care of |
| + // NotifyPlaybackStarted() when it finishes. |
| + if (!was_suspended) |
| + NotifyPlaybackStarted(); |
|
sandersd (OOO until July 31)
2016/02/27 00:22:20
If you swap the order, then no test is needed beca
DaleCurtis
2016/02/27 00:55:23
Done.
|
| + } |
| } |
| void WebMediaPlayerImpl::pause() { |
| @@ -435,6 +446,12 @@ void WebMediaPlayerImpl::DoSeek(base::TimeDelta time, bool time_updated) { |
| if (paused_) |
| paused_time_ = time; |
| pipeline_controller_.Seek(time, time_updated); |
| + |
| + // Resume the pipeline if the seek is initiated in the foreground so that |
| + // the correct frame is displayed. If the pipeline is not suspended, Resume() |
| + // will do nothing but clear some pending state -- thus always call it. |
| + if (delegate_ && !delegate_->IsHidden()) |
| + pipeline_controller_.Resume(); |
| } |
| void WebMediaPlayerImpl::setRate(double rate) { |
| @@ -1327,7 +1344,7 @@ WebMediaPlayerImpl::GetCurrentFrameFromCompositor() { |
| void WebMediaPlayerImpl::NotifyPlaybackStarted() { |
| #if defined(OS_ANDROID) // WMPI_CAST |
| - // We do not tell our delegates about remote playback, becuase that would |
| + // We do not tell our delegates about remote playback, because that would |
| // keep the device awake, which is not what we want. |
| if (isRemote()) |
| return; |