| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/media/session/pepper_player_delegate.h" |
| 6 |
| 7 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 8 #include "content/browser/media/session/pepper_playback_observer.h" |
| 9 #include "content/browser/web_contents/web_contents_impl.h" |
| 10 #include "content/common/frame_messages.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 namespace { |
| 15 |
| 16 const double kDuckVolume = 0.2f; |
| 17 |
| 18 } // anonymous namespace |
| 19 |
| 20 const int PepperPlayerDelegate::kPlayerId = 0; |
| 21 |
| 22 PepperPlayerDelegate::PepperPlayerDelegate( |
| 23 WebContentsImpl* contents, int32_t pp_instance) |
| 24 : contents_(contents), |
| 25 pp_instance_(pp_instance) {} |
| 26 |
| 27 PepperPlayerDelegate::~PepperPlayerDelegate() = default; |
| 28 |
| 29 void PepperPlayerDelegate::OnSuspend(int player_id) { |
| 30 // Pepper player cannot be really suspended. Duck the volume instead. |
| 31 DCHECK_EQ(player_id, kPlayerId); |
| 32 SetVolume(player_id, kDuckVolume); |
| 33 } |
| 34 |
| 35 void PepperPlayerDelegate::OnResume(int player_id) { |
| 36 DCHECK_EQ(player_id, kPlayerId); |
| 37 SetVolume(player_id, 1.0f); |
| 38 } |
| 39 |
| 40 void PepperPlayerDelegate::OnSetVolumeMultiplier(int player_id, |
| 41 double volume_multiplier) { |
| 42 DCHECK_EQ(player_id, kPlayerId); |
| 43 SetVolume(player_id, volume_multiplier); |
| 44 } |
| 45 |
| 46 void PepperPlayerDelegate::SetVolume(int player_id, double volume) { |
| 47 contents_->Send(new FrameMsg_SetPepperVolume( |
| 48 contents_->GetMainFrame()->routing_id(), pp_instance_, volume)); |
| 49 } |
| 50 |
| 51 } // namespace content |
| OLD | NEW |