OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/media/android/remote/remote_media_player_manager.h" | 5 #include "chrome/browser/media/android/remote/remote_media_player_manager.h" |
6 | 6 |
7 #include "chrome/browser/android/tab_android.h" | 7 #include "chrome/browser/android/tab_android.h" |
8 #include "chrome/common/chrome_content_client.h" | 8 #include "chrome/common/chrome_content_client.h" |
9 #include "content/common/media/media_player_messages_android.h" | 9 #include "content/common/media/media_player_messages_android.h" |
10 #include "third_party/skia/include/core/SkBitmap.h" | 10 #include "third_party/skia/include/core/SkBitmap.h" |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 RemoteMediaPlayerBridge* player = new RemoteMediaPlayerBridge( | 128 RemoteMediaPlayerBridge* player = new RemoteMediaPlayerBridge( |
129 local_player, | 129 local_player, |
130 GetUserAgent(), | 130 GetUserAgent(), |
131 false, | 131 false, |
132 this); | 132 this); |
133 alternative_players_.push_back(player); | 133 alternative_players_.push_back(player); |
134 player->Initialize(); | 134 player->Initialize(); |
135 return player; | 135 return player; |
136 } | 136 } |
137 | 137 |
138 // OnSuspend and OnResume are called when the local player loses or gains | |
139 // audio focus. If we are playing remotely then ignore these. | |
140 void RemoteMediaPlayerManager::OnSuspend(int player_id) { | |
141 if (!IsPlayingRemotely(player_id)) | |
142 BrowserMediaPlayerManager::OnSuspend(player_id); | |
143 } | |
144 | |
145 void RemoteMediaPlayerManager::OnResume(int player_id) { | |
146 if (!IsPlayingRemotely(player_id)) | |
147 BrowserMediaPlayerManager::OnResume(player_id); | |
148 } | |
149 | |
150 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) { | 138 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) { |
151 // Find the remote player | 139 // Find the remote player |
152 auto it = GetAlternativePlayer(player_id); | 140 auto it = GetAlternativePlayer(player_id); |
153 if (it == alternative_players_.end()) | 141 if (it == alternative_players_.end()) |
154 return; | 142 return; |
155 MediaPlayerAndroid* new_player = *it; | 143 MediaPlayerAndroid* new_player = *it; |
156 scoped_ptr<MediaPlayerAndroid> old_player = SwapPlayer(player_id, new_player); | 144 scoped_ptr<MediaPlayerAndroid> old_player = SwapPlayer(player_id, new_player); |
157 alternative_players_.weak_erase(it); | 145 alternative_players_.weak_erase(it); |
158 alternative_players_.push_back(old_player.release()); | 146 alternative_players_.push_back(old_player.release()); |
159 } | 147 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration, | 256 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration, |
269 width, height, success); | 257 width, height, success); |
270 } | 258 } |
271 } | 259 } |
272 | 260 |
273 bool RemoteMediaPlayerManager::IsPlayingRemotely(int player_id) { | 261 bool RemoteMediaPlayerManager::IsPlayingRemotely(int player_id) { |
274 return players_playing_remotely_.count(player_id) != 0; | 262 return players_playing_remotely_.count(player_id) != 0; |
275 } | 263 } |
276 | 264 |
277 } // namespace remote_media | 265 } // namespace remote_media |
OLD | NEW |