summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--webkit/glue/webmediaplayer_impl.cc13
-rw-r--r--webkit/glue/webmediaplayer_impl.h9
2 files changed, 18 insertions, 4 deletions
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
index 9f5702f..3bd5138 100644
--- a/webkit/glue/webmediaplayer_impl.cc
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -167,6 +167,8 @@ WebMediaPlayerImpl::WebMediaPlayerImpl(WebKit::WebMediaPlayerClient* client,
main_loop_(NULL),
filter_factory_(factory),
pipeline_thread_("PipelineThread"),
+ paused_(true),
+ playback_rate_(0.0f),
client_(client) {
// Saves the current message loop.
DCHECK(!main_loop_);
@@ -224,14 +226,14 @@ void WebMediaPlayerImpl::cancelLoad() {
void WebMediaPlayerImpl::play() {
DCHECK(MessageLoop::current() == main_loop_);
- // TODO(hclam): We should restore the previous playback rate rather than
- // having it at 1.0.
- pipeline_->SetPlaybackRate(1.0f);
+ paused_ = false;
+ pipeline_->SetPlaybackRate(playback_rate_);
}
void WebMediaPlayerImpl::pause() {
DCHECK(MessageLoop::current() == main_loop_);
+ paused_ = true;
pipeline_->SetPlaybackRate(0.0f);
}
@@ -257,7 +259,10 @@ void WebMediaPlayerImpl::setEndTime(float seconds) {
void WebMediaPlayerImpl::setRate(float rate) {
DCHECK(MessageLoop::current() == main_loop_);
- pipeline_->SetPlaybackRate(rate);
+ playback_rate_ = rate;
+ if (!paused_) {
+ pipeline_->SetPlaybackRate(rate);
+ }
}
void WebMediaPlayerImpl::setVolume(float volume) {
diff --git a/webkit/glue/webmediaplayer_impl.h b/webkit/glue/webmediaplayer_impl.h
index b8a44b0..c13d30f 100644
--- a/webkit/glue/webmediaplayer_impl.h
+++ b/webkit/glue/webmediaplayer_impl.h
@@ -252,6 +252,15 @@ class WebMediaPlayerImpl : public WebKit::WebMediaPlayer,
scoped_ptr<media::PipelineImpl> pipeline_;
base::Thread pipeline_thread_;
+ // Playback state.
+ //
+ // TODO(scherkus): we have these because Pipeline favours the simplicity of a
+ // single "playback rate" over worrying about paused/stopped etc... It forces
+ // all clients to manage the pause+playback rate externally, but is that
+ // really a bad thing?
+ bool paused_;
+ float playback_rate_;
+
WebKit::WebMediaPlayerClient* client_;
scoped_refptr<Proxy> proxy_;