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

Side by Side Diff: chrome/browser/media/android/remote/remote_media_player_manager.cc

Issue 1570043002: Implement MediaSession on top of the WebMediaPlayerDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@media_session
Patch Set: Created 4 years, 11 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 unified diff | Download patch
OLDNEW
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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 RemoteMediaPlayerBridge* player = new RemoteMediaPlayerBridge( 122 RemoteMediaPlayerBridge* player = new RemoteMediaPlayerBridge(
123 local_player, 123 local_player,
124 GetUserAgent(), 124 GetUserAgent(),
125 false, 125 false,
126 this); 126 this);
127 alternative_players_.push_back(player); 127 alternative_players_.push_back(player);
128 player->Initialize(); 128 player->Initialize();
129 return player; 129 return player;
130 } 130 }
131 131
132 // OnSuspend and OnResume are called when the local player loses or gains
133 // audio focus. If we are playing remotely then ignore these.
134 void RemoteMediaPlayerManager::OnSuspend(int player_id) {
135 if (!IsPlayingRemotely(player_id))
136 BrowserMediaPlayerManager::OnSuspend(player_id);
137 }
138
139 void RemoteMediaPlayerManager::OnResume(int player_id) {
140 if (!IsPlayingRemotely(player_id))
141 BrowserMediaPlayerManager::OnResume(player_id);
142 }
143
144 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) { 132 void RemoteMediaPlayerManager::SwapCurrentPlayer(int player_id) {
145 // Find the remote player 133 // Find the remote player
146 auto it = GetAlternativePlayer(player_id); 134 auto it = GetAlternativePlayer(player_id);
147 if (it == alternative_players_.end()) 135 if (it == alternative_players_.end())
148 return; 136 return;
149 MediaPlayerAndroid* new_player = *it; 137 MediaPlayerAndroid* new_player = *it;
150 scoped_ptr<MediaPlayerAndroid> old_player = SwapPlayer(player_id, new_player); 138 scoped_ptr<MediaPlayerAndroid> old_player = SwapPlayer(player_id, new_player);
151 alternative_players_.weak_erase(it); 139 alternative_players_.weak_erase(it);
152 alternative_players_.push_back(old_player.release()); 140 alternative_players_.push_back(old_player.release());
153 } 141 }
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration, 250 BrowserMediaPlayerManager::OnMediaMetadataChanged(player_id, duration,
263 width, height, success); 251 width, height, success);
264 } 252 }
265 } 253 }
266 254
267 bool RemoteMediaPlayerManager::IsPlayingRemotely(int player_id) { 255 bool RemoteMediaPlayerManager::IsPlayingRemotely(int player_id) {
268 return players_playing_remotely_.count(player_id) != 0; 256 return players_playing_remotely_.count(player_id) != 0;
269 } 257 }
270 258
271 } // namespace remote_media 259 } // namespace remote_media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698