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

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2251073003: Pretend the video has no audio track if it is playing as part of autoplay muted. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 529 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 } 540 }
541 } 541 }
542 542
543 void WebMediaPlayerImpl::setVolume(double volume) { 543 void WebMediaPlayerImpl::setVolume(double volume) {
544 DVLOG(1) << __func__ << "(" << volume << ")"; 544 DVLOG(1) << __func__ << "(" << volume << ")";
545 DCHECK(main_task_runner_->BelongsToCurrentThread()); 545 DCHECK(main_task_runner_->BelongsToCurrentThread());
546 volume_ = volume; 546 volume_ = volume;
547 pipeline_.SetVolume(volume_ * volume_multiplier_); 547 pipeline_.SetVolume(volume_ * volume_multiplier_);
548 if (watch_time_reporter_) 548 if (watch_time_reporter_)
549 watch_time_reporter_->OnVolumeChange(volume); 549 watch_time_reporter_->OnVolumeChange(volume);
550
551 // The play state is updated because the player might have left the autoplay
552 // muted state.
553 UpdatePlayState();
550 } 554 }
551 555
552 void WebMediaPlayerImpl::setSinkId( 556 void WebMediaPlayerImpl::setSinkId(
553 const blink::WebString& sink_id, 557 const blink::WebString& sink_id,
554 const blink::WebSecurityOrigin& security_origin, 558 const blink::WebSecurityOrigin& security_origin,
555 blink::WebSetSinkIdCallbacks* web_callback) { 559 blink::WebSetSinkIdCallbacks* web_callback) {
556 DCHECK(main_task_runner_->BelongsToCurrentThread()); 560 DCHECK(main_task_runner_->BelongsToCurrentThread());
557 DVLOG(1) << __func__; 561 DVLOG(1) << __func__;
558 562
559 media::OutputDeviceStatusCB callback = 563 media::OutputDeviceStatusCB callback =
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 bool is_backgrounded = 1651 bool is_backgrounded =
1648 IsBackgroundedSuspendEnabled() && delegate_ && delegate_->IsHidden(); 1652 IsBackgroundedSuspendEnabled() && delegate_ && delegate_->IsHidden();
1649 PlayState state = UpdatePlayState_ComputePlayState(is_remote, is_suspended, 1653 PlayState state = UpdatePlayState_ComputePlayState(is_remote, is_suspended,
1650 is_backgrounded); 1654 is_backgrounded);
1651 SetDelegateState(state.delegate_state); 1655 SetDelegateState(state.delegate_state);
1652 SetMemoryReportingState(state.is_memory_reporting_enabled); 1656 SetMemoryReportingState(state.is_memory_reporting_enabled);
1653 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); 1657 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_);
1654 } 1658 }
1655 1659
1656 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) { 1660 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) {
1657 if (!delegate_ || delegate_state_ == new_state) 1661 if (!delegate_)
1658 return; 1662 return;
1659 1663
1664 if (delegate_state_ == new_state) {
1665 if (delegate_state_ != DelegateState::PLAYING ||
1666 autoplay_muted_ == client_->isAutoplayingMuted()) {
1667 return;
1668 }
1669 }
1670
1660 delegate_state_ = new_state; 1671 delegate_state_ = new_state;
1661 1672
1662 switch (delegate_state_) { 1673 switch (delegate_state_) {
1663 case DelegateState::GONE: 1674 case DelegateState::GONE:
1664 delegate_->PlayerGone(delegate_id_); 1675 delegate_->PlayerGone(delegate_id_);
1665 break; 1676 break;
1666 case DelegateState::PLAYING: 1677 case DelegateState::PLAYING: {
1678 autoplay_muted_ = client_->isAutoplayingMuted();
1679 bool has_audio = autoplay_muted_ ? false : hasAudio();
1667 delegate_->DidPlay( 1680 delegate_->DidPlay(
1668 delegate_id_, hasVideo(), hasAudio(), false, 1681 delegate_id_, hasVideo(), has_audio, false,
1669 media::DurationToMediaContentType(pipeline_.GetMediaDuration())); 1682 media::DurationToMediaContentType(pipeline_.GetMediaDuration()));
1670 break; 1683 break;
1684 }
1671 case DelegateState::PAUSED: 1685 case DelegateState::PAUSED:
1672 delegate_->DidPause(delegate_id_, false); 1686 delegate_->DidPause(delegate_id_, false);
1673 break; 1687 break;
1674 case DelegateState::ENDED: 1688 case DelegateState::ENDED:
1675 delegate_->DidPause(delegate_id_, true); 1689 delegate_->DidPause(delegate_id_, true);
1676 break; 1690 break;
1677 } 1691 }
1678 } 1692 }
1679 1693
1680 void WebMediaPlayerImpl::SetMemoryReportingState( 1694 void WebMediaPlayerImpl::SetMemoryReportingState(
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1893 pipeline_metadata_.natural_size, 1907 pipeline_metadata_.natural_size,
1894 base::Bind(&GetCurrentTimeInternal, this))); 1908 base::Bind(&GetCurrentTimeInternal, this)));
1895 watch_time_reporter_->OnVolumeChange(volume_); 1909 watch_time_reporter_->OnVolumeChange(volume_);
1896 if (delegate_ && delegate_->IsHidden()) 1910 if (delegate_ && delegate_->IsHidden())
1897 watch_time_reporter_->OnHidden(); 1911 watch_time_reporter_->OnHidden();
1898 else 1912 else
1899 watch_time_reporter_->OnShown(); 1913 watch_time_reporter_->OnShown();
1900 } 1914 }
1901 1915
1902 } // namespace media 1916 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698