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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 RemoteMediaPlayerBridge* player = new RemoteMediaPlayerBridge( | 138 RemoteMediaPlayerBridge* player = new RemoteMediaPlayerBridge( |
139 local_player, | 139 local_player, |
140 GetUserAgent(), | 140 GetUserAgent(), |
141 false, | 141 false, |
142 this); | 142 this); |
143 alternative_players_.push_back(player); | 143 alternative_players_.push_back(player); |
144 player->Initialize(); | 144 player->Initialize(); |
145 return player; | 145 return player; |
146 } | 146 } |
147 | 147 |
148 // OnSuspend and OnResume are called when the local player loses or gains | |
149 // audio focus. If we are playing remotely then ignore these. | |
150 void RemoteMediaPlayerManager::OnSuspend(int player_id) { | |
151 if (!IsPlayingRemotely(player_id)) | |
152 BrowserMediaPlayerManager::OnSuspend(player_id); | |
153 } | |
154 | |
155 void RemoteMediaPlayerManager::OnResume(int player_id) { | |
156 if (!IsPlayingRemotely(player_id)) | |
157 BrowserMediaPlayerManager::OnResume(player_id); | |
158 } | |
159 | |
160 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) { | 148 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) { |
161 // Find the remote player | 149 // Find the remote player |
162 auto it = GetAlternativePlayer(player_id); | 150 auto it = GetAlternativePlayer(player_id); |
163 if (it == alternative_players_.end()) | 151 if (it == alternative_players_.end()) |
164 return; | 152 return; |
165 MediaPlayerAndroid* new_player = *it; | 153 MediaPlayerAndroid* new_player = *it; |
166 scoped_ptr<MediaPlayerAndroid> old_player = SwapPlayer(player_id, new_player); | 154 scoped_ptr<MediaPlayerAndroid> old_player = SwapPlayer(player_id, new_player); |
167 alternative_players_.weak_erase(it); | 155 alternative_players_.weak_erase(it); |
168 alternative_players_.push_back(old_player.release()); | 156 alternative_players_.push_back(old_player.release()); |
169 } | 157 } |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 MediaPlayerAndroid* local_player = GetLocalPlayer(player_id); | 264 MediaPlayerAndroid* local_player = GetLocalPlayer(player_id); |
277 Send(new MediaPlayerMsg_MediaMetadataChanged( | 265 Send(new MediaPlayerMsg_MediaMetadataChanged( |
278 RoutingID(), player_id, duration, local_player->GetVideoWidth(), | 266 RoutingID(), player_id, duration, local_player->GetVideoWidth(), |
279 local_player->GetVideoHeight(), success)); | 267 local_player->GetVideoHeight(), success)); |
280 } else { | 268 } else { |
281 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration, | 269 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration, |
282 width, height, success); | 270 width, height, success); |
283 } | 271 } |
284 } | 272 } |
285 } // namespace remote_media | 273 } // namespace remote_media |
OLD | NEW |