Chromium Code Reviews| Index: content/browser/media/session/media_session_impl.cc |
| diff --git a/content/browser/media/session/media_session_impl.cc b/content/browser/media/session/media_session_impl.cc |
| index bedae34f22e869fb82ab0414fc1935706116fd5b..26448557519ca0ef5d1275658e14c68a0e830f84 100644 |
| --- a/content/browser/media/session/media_session_impl.cc |
| +++ b/content/browser/media/session/media_session_impl.cc |
| @@ -611,6 +611,37 @@ void MediaSessionImpl::OnMediaSessionActionsChanged( |
| void MediaSessionImpl::DidReceiveAction( |
| blink::mojom::MediaSessionAction action) { |
| + // Pause all players in non-routed frames if the action is PAUSE. |
| + // |
| + // This is the default PAUSE action handler as mentioned in the Media Session |
| + // API spec. The reason for pausing all players in all other sessions is to |
| + // avoid the players in other frames keep the session active so that the UI |
| + // will always show the pause button but it does not pause anything (as the |
| + // routed frame already pauses when responding to the PAUSE action while other |
| + // frames does not). |
| + // |
| + // TODO(zqzhang): Currently, this might not work well on desktop as Pepper and |
| + // OneShot players are not really suspended, so that the session is still |
| + // active after this. See https://crbug.com/619084 and |
| + // https://crbug.com/596516. |
| + if (blink::mojom::MediaSessionAction::PAUSE == action) { |
| + RenderFrameHost* rfh_of_routed_service = |
| + routed_service_->GetRenderFrameHost(); |
| + for (const auto& player : normal_players_) { |
| + if (player.observer->GetRenderFrameHost() != rfh_of_routed_service) |
| + player.observer->OnSuspend(player.player_id); |
| + } |
| + for (const auto& player : pepper_players_) { |
| + if (player.observer->GetRenderFrameHost() != rfh_of_routed_service) |
|
mlamouri (slow - plz ping)
2017/02/10 14:17:43
styte: you need { } because the statement is in tw
Zhiqiang Zhang (Slow)
2017/02/10 14:25:58
Done.
|
| + player.observer->OnSetVolumeMultiplier( |
| + player.player_id, kDuckingVolumeMultiplier); |
| + } |
| + for (const auto& player : one_shot_players_) { |
| + if (player.observer->GetRenderFrameHost() != rfh_of_routed_service) |
| + player.observer->OnSuspend(player.player_id); |
| + } |
| + } |
| + |
| if (!routed_service_) |
| return; |