Skip to content

Commit

Permalink
Remove secondary player from Media Sessions
Browse files Browse the repository at this point in the history
When we switch Android media players, for cast, we no longer want audio
focus changes associated with old player to take effect. To handle this
remove the old player from the Media Sessions.

The new player is responsible for adding itself to the Media Sessions if
it needs to. The remote player doesn't need to, and, after stopping casting
the local player will do so when the user presses play.

BUG=595373

Review URL: https://codereview.chromium.org/1823983002

Cr-Commit-Position: refs/heads/master@{#382613}
  • Loading branch information
aberent authored and Commit bot committed Mar 22, 2016
1 parent ea712f8 commit 4bee90c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
3 changes: 3 additions & 0 deletions content/browser/media/android/browser_media_player_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,9 @@ scoped_ptr<media::MediaPlayerAndroid> BrowserMediaPlayerManager::SwapPlayer(
#if defined(VIDEO_HOLE)
ReleaseExternalSurface(player_id);
#endif
MediaWebContentsObserverAndroid::FromWebContents(web_contents_)
->DisconnectMediaSession(render_frame_host_,
player_id_to_delegate_id_map_[player_id]);
players_.weak_erase(it);
players_.push_back(player);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ bool MediaWebContentsObserverAndroid::RequestPlay(
has_audio, is_remote, duration);
}

void MediaWebContentsObserverAndroid::DisconnectMediaSession(
RenderFrameHost* render_frame_host,
int delegate_id) {
session_controllers_manager()->OnEnd(
MediaPlayerId(render_frame_host, delegate_id));
}

#if defined(VIDEO_HOLE)
void MediaWebContentsObserverAndroid::OnFrameInfoUpdated() {
for (auto it = media_player_managers_.begin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@ class CONTENT_EXPORT MediaWebContentsObserverAndroid
bool is_remote,
base::TimeDelta duration);

void DisconnectMediaSession(RenderFrameHost* render_frame_host,
int delegate_id);

#if defined(VIDEO_HOLE)
void OnFrameInfoUpdated();
#endif // defined(VIDEO_HOLE)
Expand Down

0 comments on commit 4bee90c

Please sign in to comment.