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

Side by Side Diff: content/browser/android/media_player_manager_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
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 "content/browser/android/media_player_manager_android.h" 5 #include "content/browser/android/media_player_manager_android.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "content/browser/android/cookie_getter_impl.h" 8 #include "content/browser/android/cookie_getter_impl.h"
9 #include "content/common/media/media_player_messages.h" 9 #include "content/common/media/media_player_messages.h"
10 #include "content/public/browser/browser_context.h" 10 #include "content/public/browser/browser_context.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 base::Unretained(this)), 116 base::Unretained(this)),
117 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate, 117 base::Bind(&MediaPlayerManagerAndroid::OnBufferingUpdate,
118 base::Unretained(this)), 118 base::Unretained(this)),
119 base::Bind(&MediaPlayerManagerAndroid::OnPrepared, 119 base::Bind(&MediaPlayerManagerAndroid::OnPrepared,
120 base::Unretained(this)), 120 base::Unretained(this)),
121 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete, 121 base::Bind(&MediaPlayerManagerAndroid::OnPlaybackComplete,
122 base::Unretained(this)), 122 base::Unretained(this)),
123 base::Bind(&MediaPlayerManagerAndroid::OnSeekComplete, 123 base::Bind(&MediaPlayerManagerAndroid::OnSeekComplete,
124 base::Unretained(this)), 124 base::Unretained(this)),
125 base::Bind(&MediaPlayerManagerAndroid::OnTimeUpdate, 125 base::Bind(&MediaPlayerManagerAndroid::OnTimeUpdate,
126 base::Unretained(this)),
127 base::Bind(&MediaPlayerManagerAndroid::OnMediaInterrupted,
126 base::Unretained(this)))); 128 base::Unretained(this))));
127 129
128 // Send a MediaPrepared message to webkit so that Load() can finish. 130 // Send a MediaPrepared message to webkit so that Load() can finish.
129 Send(new MediaPlayerMsg_MediaPrepared( 131 Send(new MediaPlayerMsg_MediaPrepared(
130 routing_id(), player_id, GetPlayer(player_id)->GetDuration())); 132 routing_id(), player_id, GetPlayer(player_id)->GetDuration()));
131 } 133 }
132 134
133 void MediaPlayerManagerAndroid::OnStart(int player_id) { 135 void MediaPlayerManagerAndroid::OnStart(int player_id) {
134 MediaPlayerBridge* player = GetPlayer(player_id); 136 MediaPlayerBridge* player = GetPlayer(player_id);
135 if (player) 137 if (player)
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 if (fullscreen_player_id_ != -1) 215 if (fullscreen_player_id_ != -1)
214 video_view_.UpdateMediaMetadata(); 216 video_view_.UpdateMediaMetadata();
215 } 217 }
216 218
217 void MediaPlayerManagerAndroid::OnPlaybackComplete(int player_id) { 219 void MediaPlayerManagerAndroid::OnPlaybackComplete(int player_id) {
218 Send(new MediaPlayerMsg_MediaPlaybackCompleted(routing_id(), player_id)); 220 Send(new MediaPlayerMsg_MediaPlaybackCompleted(routing_id(), player_id));
219 if (fullscreen_player_id_ != -1) 221 if (fullscreen_player_id_ != -1)
220 video_view_.OnPlaybackComplete(); 222 video_view_.OnPlaybackComplete();
221 } 223 }
222 224
225 void MediaPlayerManagerAndroid::OnMediaInterrupted(int player_id) {
226 // Tell WebKit that the audio should be paused, then release all resources
227 Send(new MediaPlayerMsg_DidMediaPlayerPause(routing_id(), player_id));
228 OnReleaseResources(player_id);
229 }
230
223 void MediaPlayerManagerAndroid::OnBufferingUpdate( 231 void MediaPlayerManagerAndroid::OnBufferingUpdate(
224 int player_id, int percentage) { 232 int player_id, int percentage) {
225 Send(new MediaPlayerMsg_MediaBufferingUpdate( 233 Send(new MediaPlayerMsg_MediaBufferingUpdate(
226 routing_id(), player_id, percentage)); 234 routing_id(), player_id, percentage));
227 if (fullscreen_player_id_ != -1) 235 if (fullscreen_player_id_ != -1)
228 video_view_.OnBufferingUpdate(percentage); 236 video_view_.OnBufferingUpdate(percentage);
229 } 237 }
230 238
231 void MediaPlayerManagerAndroid::OnSeekComplete(int player_id, 239 void MediaPlayerManagerAndroid::OnSeekComplete(int player_id,
232 base::TimeDelta current_time) { 240 base::TimeDelta current_time) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 } 293 }
286 } 294 }
287 } 295 }
288 296
289 void MediaPlayerManagerAndroid::ReleaseMediaResources( 297 void MediaPlayerManagerAndroid::ReleaseMediaResources(
290 MediaPlayerBridge* player) { 298 MediaPlayerBridge* player) {
291 // Nothing needs to be done. 299 // Nothing needs to be done.
292 } 300 }
293 301
294 } // namespace content 302 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/android/media_player_manager_android.h ('k') | content/shell/android/java/AndroidManifest.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698