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

Side by Side Diff: webkit/media/android/webmediaplayer_in_process_android.cc

Issue 11348199: Free (and pause) audio resources when getting a phone call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_color
Patch Set: Created 8 years 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 unified diff | Download patch
« no previous file with comments | « webkit/media/android/webmediaplayer_in_process_android.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "webkit/media/android/webmediaplayer_in_process_android.h" 5 #include "webkit/media/android/webmediaplayer_in_process_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "media/base/android/media_player_bridge.h" 10 #include "media/base/android/media_player_bridge.h"
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 // is completed. 102 // is completed.
103 playback_completed_ = true; 103 playback_completed_ = true;
104 client()->timeChanged(); 104 client()->timeChanged();
105 } 105 }
106 106
107 void WebMediaPlayerInProcessAndroid::SeekCompleteCallback( 107 void WebMediaPlayerInProcessAndroid::SeekCompleteCallback(
108 int player_id, base::TimeDelta current_time) { 108 int player_id, base::TimeDelta current_time) {
109 OnSeekComplete(current_time); 109 OnSeekComplete(current_time);
110 } 110 }
111 111
112 void WebMediaPlayerInProcessAndroid::MediaInterruptedCallback(int player_id) {
113 PauseInternal();
114 }
115
112 void WebMediaPlayerInProcessAndroid::MediaErrorCallback(int player_id, 116 void WebMediaPlayerInProcessAndroid::MediaErrorCallback(int player_id,
113 int error_type) { 117 int error_type) {
114 OnMediaError(error_type); 118 OnMediaError(error_type);
115 } 119 }
116 120
117 void WebMediaPlayerInProcessAndroid::VideoSizeChangedCallback( 121 void WebMediaPlayerInProcessAndroid::VideoSizeChangedCallback(
118 int player_id, int width, int height) { 122 int player_id, int width, int height) {
119 OnVideoSizeChanged(width, height); 123 OnVideoSizeChanged(width, height);
120 } 124 }
121 125
(...skipping 19 matching lines...) Expand all
141 base::Unretained(this)), 145 base::Unretained(this)),
142 base::Bind(&WebMediaPlayerInProcessAndroid::BufferingUpdateCallback, 146 base::Bind(&WebMediaPlayerInProcessAndroid::BufferingUpdateCallback,
143 base::Unretained(this)), 147 base::Unretained(this)),
144 base::Bind(&WebMediaPlayerInProcessAndroid::MediaPreparedCallback, 148 base::Bind(&WebMediaPlayerInProcessAndroid::MediaPreparedCallback,
145 base::Unretained(this)), 149 base::Unretained(this)),
146 base::Bind(&WebMediaPlayerInProcessAndroid::PlaybackCompleteCallback, 150 base::Bind(&WebMediaPlayerInProcessAndroid::PlaybackCompleteCallback,
147 base::Unretained(this)), 151 base::Unretained(this)),
148 base::Bind(&WebMediaPlayerInProcessAndroid::SeekCompleteCallback, 152 base::Bind(&WebMediaPlayerInProcessAndroid::SeekCompleteCallback,
149 base::Unretained(this)), 153 base::Unretained(this)),
150 base::Bind(&WebMediaPlayerInProcessAndroid::TimeUpdateCallback, 154 base::Bind(&WebMediaPlayerInProcessAndroid::TimeUpdateCallback,
155 base::Unretained(this)),
156 base::Bind(&WebMediaPlayerInProcessAndroid::MediaInterruptedCallback,
151 base::Unretained(this)))); 157 base::Unretained(this))));
152 158
153 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading); 159 UpdateNetworkState(WebMediaPlayer::NetworkStateLoading);
154 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing); 160 UpdateReadyState(WebMediaPlayer::ReadyStateHaveNothing);
155 161
156 // Calling Prepare() will cause android mediaplayer to start 162 // Calling Prepare() will cause android mediaplayer to start
157 // buffering and decoding the data. On mobile devices, this costs a lot of 163 // buffering and decoding the data. On mobile devices, this costs a lot of
158 // data usage and could even introduce performance issues. So we don't 164 // data usage and could even introduce performance issues. So we don't
159 // initialize the player unless it is a local file. We will start loading 165 // initialize the player unless it is a local file. We will start loading
160 // the media only when play/seek/fullsceen button is clicked. 166 // the media only when play/seek/fullsceen button is clicked.
161 if (url.SchemeIs("file")) { 167 if (url.SchemeIs("file")) {
162 media_player_->Prepare(); 168 media_player_->Prepare();
163 return; 169 return;
164 } 170 }
165 171
166 // Pretend everything has been loaded so that webkit can 172 // Pretend everything has been loaded so that webkit can
167 // still call play() and seek(). 173 // still call play() and seek().
168 UpdateReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 174 UpdateReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
169 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData); 175 UpdateReadyState(WebMediaPlayer::ReadyStateHaveEnoughData);
170 } 176 }
171 177
172 void WebMediaPlayerInProcessAndroid::OnTimeUpdate( 178 void WebMediaPlayerInProcessAndroid::OnTimeUpdate(
173 base::TimeDelta current_time) {} 179 base::TimeDelta current_time) {}
174 180
175 void WebMediaPlayerInProcessAndroid::Destroy() {} 181 void WebMediaPlayerInProcessAndroid::Destroy() {}
176 182
177 } // namespace webkit_media 183 } // namespace webkit_media
OLDNEW
« no previous file with comments | « webkit/media/android/webmediaplayer_in_process_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698