Chromium Code Reviews| Index: content/browser/media/session/pepper_player_delegate.cc |
| diff --git a/content/browser/media/session/pepper_player_delegate.cc b/content/browser/media/session/pepper_player_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e4e31b89919157b694463c89b7c8978306190f2c |
| --- /dev/null |
| +++ b/content/browser/media/session/pepper_player_delegate.cc |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/media/session/pepper_player_delegate.h" |
| + |
| +#include "content/browser/frame_host/render_frame_host_impl.h" |
| +#include "content/browser/media/session/pepper_playback_observer.h" |
| +#include "content/browser/web_contents/web_contents_impl.h" |
| +#include "content/common/frame_messages.h" |
| + |
| +namespace content { |
| + |
| +namespace { |
| +const double kDuckVolume = 0.2f; |
| +const int kPlayerId = 0; |
|
dcheng
2016/07/01 05:57:59
Note: this is fine, but my comment was directed mo
Zhiqiang Zhang (Slow)
2016/07/01 11:01:07
OK, now I moved all the Ids in one place (pepper_p
|
| +} // anonymous namespace |
| + |
| +PepperPlayerDelegate::PepperPlayerDelegate( |
| + WebContentsImpl* contents, int32_t pp_instance) |
| + : contents_(contents), |
| + pp_instance_(pp_instance) {} |
| + |
| +PepperPlayerDelegate::~PepperPlayerDelegate() = default; |
| + |
| +void PepperPlayerDelegate::OnSuspend(int player_id) { |
| + // Pepper player cannot be really suspended. Duck the volume instead. |
| + DCHECK_EQ(player_id, kPlayerId); |
| + SetVolume(player_id, kDuckVolume); |
| +} |
| + |
| +void PepperPlayerDelegate::OnResume(int player_id) { |
| + DCHECK_EQ(player_id, kPlayerId); |
| + SetVolume(player_id, 1.0f); |
| +} |
| + |
| +void PepperPlayerDelegate::OnSetVolumeMultiplier(int player_id, |
| + double volume_multiplier) { |
| + DCHECK_EQ(player_id, kPlayerId); |
| + SetVolume(player_id, volume_multiplier); |
| +} |
| + |
| +void PepperPlayerDelegate::SetVolume(int player_id, double volume) { |
| + contents_->Send(new FrameMsg_SetPepperVolume( |
| + contents_->GetMainFrame()->routing_id(), pp_instance_, volume)); |
| +} |
| + |
| +} // namespace content |