Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: webkit/glue/webmediaplayer_impl.cc

Issue 8399023: Fire canplaythrough event at the proper time for audio/video (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responses to CR Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/glue/webmediaplayer_impl.cc
diff --git a/webkit/glue/webmediaplayer_impl.cc b/webkit/glue/webmediaplayer_impl.cc
index 01ddcc06c9191fef3966592df87892058792b880..7a8c166bb924e1bc56ad4e311d25c8dba2c77955 100644
--- a/webkit/glue/webmediaplayer_impl.cc
+++ b/webkit/glue/webmediaplayer_impl.cc
@@ -42,6 +42,7 @@
using WebKit::WebCanvas;
using WebKit::WebRect;
using WebKit::WebSize;
+using media::NetworkEvent;
using media::PipelineStatus;
namespace {
@@ -342,9 +343,8 @@ void WebMediaPlayerImpl::seek(float seconds) {
base::TimeDelta seek_time = ConvertSecondsToTimestamp(seconds);
// Update our paused time.
- if (paused_) {
+ if (paused_)
paused_time_ = seek_time;
- }
seeking_ = true;
@@ -465,9 +465,8 @@ float WebMediaPlayerImpl::duration() const {
float WebMediaPlayerImpl::currentTime() const {
DCHECK_EQ(main_loop_, MessageLoop::current());
- if (paused_) {
+ if (paused_)
return static_cast<float>(paused_time_.InSecondsF());
- }
return static_cast<float>(pipeline_->GetCurrentTime().InSecondsF());
}
@@ -708,15 +707,11 @@ void WebMediaPlayerImpl::OnPipelineInitialize(PipelineStatus status) {
static_cast<float>(pipeline_->GetMediaDuration().InSecondsF());
buffered_.swap(new_buffered);
- if (pipeline_->IsLoaded()) {
+ if (pipeline_->IsLoaded())
SetNetworkState(WebKit::WebMediaPlayer::Loaded);
- }
- // Since we have initialized the pipeline, say we have everything otherwise
- // we'll remain either loading/idle.
- // TODO(hclam): change this to report the correct status.
SetReadyState(WebKit::WebMediaPlayer::HaveMetadata);
- SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
+ SetReadyState(WebKit::WebMediaPlayer::HaveFutureData);
} else {
// TODO(hclam): should use |status| to determine the state
// properly and reports error using MediaError.
@@ -741,20 +736,17 @@ void WebMediaPlayerImpl::OnPipelineSeek(PipelineStatus status) {
if (status == media::PIPELINE_OK) {
// Update our paused time.
- if (paused_) {
+ if (paused_)
paused_time_ = pipeline_->GetCurrentTime();
- }
- SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
GetClient()->timeChanged();
}
}
void WebMediaPlayerImpl::OnPipelineEnded(PipelineStatus status) {
DCHECK_EQ(main_loop_, MessageLoop::current());
- if (status == media::PIPELINE_OK) {
+ if (status == media::PIPELINE_OK)
GetClient()->timeChanged();
- }
}
void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) {
@@ -798,12 +790,21 @@ void WebMediaPlayerImpl::OnPipelineError(PipelineStatus error) {
Repaint();
}
-void WebMediaPlayerImpl::OnNetworkEvent(bool is_downloading_data) {
+void WebMediaPlayerImpl::OnNetworkEvent(NetworkEvent type) {
DCHECK_EQ(main_loop_, MessageLoop::current());
- if (is_downloading_data)
- SetNetworkState(WebKit::WebMediaPlayer::Loading);
- else
- SetNetworkState(WebKit::WebMediaPlayer::Idle);
+ switch(type) {
+ case media::DOWNLOAD_CONTINUED:
+ SetNetworkState(WebKit::WebMediaPlayer::Loading);
+ break;
+ case media::DOWNLOAD_PAUSED:
+ SetNetworkState(WebKit::WebMediaPlayer::Idle);
+ break;
+ case media::CAN_PLAY_THROUGH:
+ SetReadyState(WebKit::WebMediaPlayer::HaveEnoughData);
+ break;
+ default:
scherkus (not reviewing) 2011/11/16 02:15:17 indentation
+ NOTREACHED();
+ }
}
void WebMediaPlayerImpl::OnDemuxerOpened() {

Powered by Google App Engine
This is Rietveld 408576698