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 e7520665b1e7e9b47c761b7e1821503476dcbccb..e79793ca029eb47c263c844ffdeebb7597193472 100644 |
--- a/content/renderer/media/android/webmediaplayer_android.cc |
+++ b/content/renderer/media/android/webmediaplayer_android.cc |
@@ -147,6 +147,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid( |
media_log_(media_log), |
web_cdm_(NULL), |
allow_stored_credentials_(false), |
+ is_local_resource_(false), |
weak_factory_(this) { |
DCHECK(player_manager_); |
DCHECK(cdm_manager_); |
@@ -217,6 +218,7 @@ void WebMediaPlayerAndroid::load(LoadType load_type, |
} |
url_ = url; |
+ is_local_resource_ = IsLocalResource(); |
int demuxer_client_id = 0; |
if (player_type_ != MEDIA_PLAYER_TYPE_URL) { |
RendererDemuxerAndroid* demuxer = |
@@ -278,6 +280,19 @@ void WebMediaPlayerAndroid::DidLoadMediaInfo( |
UpdateNetworkState(WebMediaPlayer::NetworkStateIdle); |
} |
+bool WebMediaPlayerAndroid::IsLocalResource() { |
+ if (url_.SchemeIsFile() || url_.SchemeIsBlob()) |
+ return true; |
+ |
+ std::string host = url_.host(); |
+ if (!host.compare("localhost") || !host.compare("127.0.0.1") || |
+ !host.compare("[::1]")) { |
+ return true; |
+ } |
+ |
+ return false; |
+} |
+ |
void WebMediaPlayerAndroid::play() { |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
@@ -691,7 +706,7 @@ void WebMediaPlayerAndroid::OnMediaMetadataChanged( |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
bool need_to_signal_duration_changed = false; |
- if (url_.SchemeIs("file")) |
+ if (is_local_resource_) |
UpdateNetworkState(WebMediaPlayer::NetworkStateLoaded); |
// Update duration, if necessary, prior to ready state updates that may |
@@ -849,6 +864,8 @@ void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) { |
void WebMediaPlayerAndroid::OnTimeUpdate(const base::TimeDelta& current_time) { |
DCHECK(main_thread_checker_.CalledOnValidThread()); |
current_time_ = current_time.InSecondsF(); |
+ if (is_local_resource_ && current_time_ <= duration()) |
+ buffered_[0].end = current_time_; |
} |
void WebMediaPlayerAndroid::OnConnectedToRemoteDevice( |