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

Unified Diff: chrome/renderer/webmediaplayer_delegate_impl.cc

Issue 100131: Finished implementing seeking in WebMediaPlayerDelegateImpl. (Closed)
Patch Set: Typo Created 11 years, 8 months 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
« no previous file with comments | « chrome/renderer/webmediaplayer_delegate_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/webmediaplayer_delegate_impl.cc
diff --git a/chrome/renderer/webmediaplayer_delegate_impl.cc b/chrome/renderer/webmediaplayer_delegate_impl.cc
index 6112cb914ebc5262c69f00fa7affa5eee9112a0d..4e811e8ef673d56cbbcf976fb9615da25f89e1db 100644
--- a/chrome/renderer/webmediaplayer_delegate_impl.cc
+++ b/chrome/renderer/webmediaplayer_delegate_impl.cc
@@ -153,6 +153,13 @@ void WebMediaPlayerDelegateImpl::Seek(float seconds) {
DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
pipeline_.Seek(base::TimeDelta::FromSeconds(static_cast<int64>(seconds)));
+
+ // Even though the seek might be in progress, WebKit's HTMLMediaElement
+ // thinks we're seeking unless we notify that the time has changed.
+ //
+ // TODO(scherkus): add a seek completion callback to the pipeline.
+ PostTask(kTimeChangedTaskIndex,
+ &webkit_glue::WebMediaPlayer::NotifyTimeChange);
}
void WebMediaPlayerDelegateImpl::SetEndTime(float seconds) {
@@ -220,8 +227,7 @@ bool WebMediaPlayerDelegateImpl::IsPaused() const {
bool WebMediaPlayerDelegateImpl::IsSeeking() const {
DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
- // TODO(hclam): Add this method call if pipeline has it in the interface.
- return false;
+ return tasks_[kTimeChangedTaskIndex] != NULL;
}
float WebMediaPlayerDelegateImpl::GetDuration() const {
@@ -265,8 +271,14 @@ float WebMediaPlayerDelegateImpl::GetMaxTimeBuffered() const {
float WebMediaPlayerDelegateImpl::GetMaxTimeSeekable() const {
DCHECK(main_loop_ && MessageLoop::current() == main_loop_);
- // TODO(hclam): add this method when pipeline has this method implemented.
- return 0.0f;
+ // TODO(scherkus): move this logic down into the pipeline.
+ if (pipeline_.GetTotalBytes() == 0) {
+ return 0.0f;
+ }
+ double total_bytes = static_cast<double>(pipeline_.GetTotalBytes());
+ double buffered_bytes = static_cast<double>(pipeline_.GetBufferedBytes());
+ double duration = static_cast<double>(pipeline_.GetDuration().InSecondsF());
+ return static_cast<float>(duration * (buffered_bytes / total_bytes));
}
int64 WebMediaPlayerDelegateImpl::GetBytesLoaded() const {
« no previous file with comments | « chrome/renderer/webmediaplayer_delegate_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698