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

Unified Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 552723003: If duration of media source is unknown then return NaN. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/android/webmediaplayer_android.cc
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 67aa9b097a3ed7e1755f7f42697bd01a9ab5a5a3..048994912aa7377092e315f14cfd0e39924acb5b 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -139,6 +139,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
has_size_info_(false),
stream_texture_factory_(factory),
needs_external_surface_(false),
+ has_valid_metadata_(false),
video_frame_provider_client_(NULL),
pending_playback_(false),
player_type_(MEDIA_PLAYER_TYPE_URL),
@@ -433,7 +434,8 @@ bool WebMediaPlayerAndroid::seeking() const {
double WebMediaPlayerAndroid::duration() const {
DCHECK(main_thread_checker_.CalledOnValidThread());
// HTML5 spec requires duration to be NaN if readyState is HAVE_NOTHING
- if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing)
+ if (ready_state_ == WebMediaPlayer::ReadyStateHaveNothing ||
+ !has_valid_metadata_)
return std::numeric_limits<double>::quiet_NaN();
if (duration_ == media::kInfiniteDuration())
@@ -487,7 +489,8 @@ WebTimeRanges WebMediaPlayerAndroid::buffered() const {
double WebMediaPlayerAndroid::maxTimeSeekable() const {
// If we haven't even gotten to ReadyStateHaveMetadata yet then just
// return 0 so that the seekable range is empty.
- if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata)
+ if (ready_state_ < WebMediaPlayer::ReadyStateHaveMetadata ||
+ !has_valid_metadata_)
return 0.0;
return duration();
@@ -737,6 +740,8 @@ void WebMediaPlayerAndroid::OnMediaMetadataChanged(
if (success)
OnVideoSizeChanged(width, height);
+ has_valid_metadata_ = success;
+
if (need_to_signal_duration_changed)
client_->durationChanged();
}
@@ -760,7 +765,7 @@ void WebMediaPlayerAndroid::OnPlaybackComplete() {
}
void WebMediaPlayerAndroid::OnBufferingUpdate(int percentage) {
- buffered_[0].end = duration() * percentage / 100;
+ buffered_[0].end = has_valid_metadata_ ? duration() * percentage / 100 : 0;
did_loading_progress_ = true;
}
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698