Commit d2c745b1 authored by scherkus's avatar scherkus Committed by Commit bot

Have WebMediaPlayerImpl track ended state.

Until we can rework the guts of HTMLMediaElement and its interaction
with WebMediaPlayer, have WebMediaPlayerImpl track an ended state so it
can return the duration HTMLMediaElement expects to fire the ended
event.

This makes it easier to change how Pipeline's audio/video time is
implemented without worrying about the pecularities of HTMLMediaElement.

BUG=349543,370634

Review URL: https://codereview.chromium.org/526443003

Cr-Commit-Position: refs/heads/master@{#293263}
parent bc80fa35
......@@ -151,6 +151,7 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(
paused_(true),
seeking_(false),
playback_rate_(0.0f),
ended_(false),
pending_seek_(false),
pending_seek_seconds_(0.0f),
should_notify_time_changed_(false),
......@@ -310,6 +311,8 @@ void WebMediaPlayerImpl::seek(double seconds) {
DVLOG(1) << __FUNCTION__ << "(" << seconds << ")";
DCHECK(main_task_runner_->BelongsToCurrentThread());
ended_ = false;
if (ready_state_ > WebMediaPlayer::ReadyStateHaveMetadata)
SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
......@@ -443,6 +446,13 @@ double WebMediaPlayerImpl::timelineOffset() const {
double WebMediaPlayerImpl::currentTime() const {
DCHECK(main_task_runner_->BelongsToCurrentThread());
DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
// TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement,
// see http://crbug.com/409280
if (ended_)
return duration();
return (paused_ ? paused_time_ : pipeline_.GetMediaTime()).InSecondsF();
}
......@@ -698,6 +708,12 @@ void WebMediaPlayerImpl::OnPipelineSeeked(bool time_changed,
void WebMediaPlayerImpl::OnPipelineEnded() {
DVLOG(1) << __FUNCTION__;
DCHECK(main_task_runner_->BelongsToCurrentThread());
// Ignore state changes until we've completed all outstanding seeks.
if (seeking_ || pending_seek_)
return;
ended_ = true;
client_->timeChanged();
}
......
......@@ -265,6 +265,10 @@ class WebMediaPlayerImpl
double playback_rate_;
base::TimeDelta paused_time_;
// TODO(scherkus): Replace with an explicit ended signal to HTMLMediaElement,
// see http://crbug.com/409280
bool ended_;
// Seek gets pending if another seek is in progress. Only last pending seek
// will have effect.
bool pending_seek_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment