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

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

Issue 496683002: Updating buffered duration of local resource in android (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing comments Created 6 years, 4 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') | media/base/android/media_player_bridge.cc » ('j') | 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 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(
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | media/base/android/media_player_bridge.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698