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

Unified Diff: content/browser/media/session/media_session_impl.cc

Issue 2660263002: [Media>Session] Pause all players for non-routed frames when receiving PAUSE action (Closed)
Patch Set: added comments and tests Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/media/session/media_session_impl_service_routing_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
« no previous file with comments | « no previous file | content/browser/media/session/media_session_impl_service_routing_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698