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

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

Issue 2471373005: Pretend the video has no audio track if it is playing as part of autoplay muted. (Closed)
Patch Set: 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 515 matching lines...) Expand 10 before | Expand all | Expand 10 after
526 } 526 }
527 } 527 }
528 528
529 void WebMediaPlayerImpl::setVolume(double volume) { 529 void WebMediaPlayerImpl::setVolume(double volume) {
530 DVLOG(1) << __func__ << "(" << volume << ")"; 530 DVLOG(1) << __func__ << "(" << volume << ")";
531 DCHECK(main_task_runner_->BelongsToCurrentThread()); 531 DCHECK(main_task_runner_->BelongsToCurrentThread());
532 volume_ = volume; 532 volume_ = volume;
533 pipeline_.SetVolume(volume_ * volume_multiplier_); 533 pipeline_.SetVolume(volume_ * volume_multiplier_);
534 if (watch_time_reporter_) 534 if (watch_time_reporter_)
535 watch_time_reporter_->OnVolumeChange(volume); 535 watch_time_reporter_->OnVolumeChange(volume);
536
537 // The play state is updated because the player might have left the autoplay
538 // muted state.
539 UpdatePlayState();
536 } 540 }
537 541
538 void WebMediaPlayerImpl::setSinkId( 542 void WebMediaPlayerImpl::setSinkId(
539 const blink::WebString& sink_id, 543 const blink::WebString& sink_id,
540 const blink::WebSecurityOrigin& security_origin, 544 const blink::WebSecurityOrigin& security_origin,
541 blink::WebSetSinkIdCallbacks* web_callback) { 545 blink::WebSetSinkIdCallbacks* web_callback) {
542 DCHECK(main_task_runner_->BelongsToCurrentThread()); 546 DCHECK(main_task_runner_->BelongsToCurrentThread());
543 DVLOG(1) << __func__; 547 DVLOG(1) << __func__;
544 548
545 media::OutputDeviceStatusCB callback = 549 media::OutputDeviceStatusCB callback =
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1614 bool is_backgrounded = 1618 bool is_backgrounded =
1615 IsBackgroundedSuspendEnabled() && delegate_ && delegate_->IsHidden(); 1619 IsBackgroundedSuspendEnabled() && delegate_ && delegate_->IsHidden();
1616 PlayState state = UpdatePlayState_ComputePlayState(is_remote, is_suspended, 1620 PlayState state = UpdatePlayState_ComputePlayState(is_remote, is_suspended,
1617 is_backgrounded); 1621 is_backgrounded);
1618 SetDelegateState(state.delegate_state); 1622 SetDelegateState(state.delegate_state);
1619 SetMemoryReportingState(state.is_memory_reporting_enabled); 1623 SetMemoryReportingState(state.is_memory_reporting_enabled);
1620 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_); 1624 SetSuspendState(state.is_suspended || pending_suspend_resume_cycle_);
1621 } 1625 }
1622 1626
1623 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) { 1627 void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) {
1624 if (!delegate_ || delegate_state_ == new_state) 1628 if (!delegate_)
1625 return; 1629 return;
1626 1630
1631 if (delegate_state_ == new_state) {
1632 if (delegate_state_ != DelegateState::PLAYING ||
1633 autoplay_muted_ == client_->isAutoplayingMuted()) {
1634 return;
1635 }
1636 }
1637
1627 delegate_state_ = new_state; 1638 delegate_state_ = new_state;
1628 1639
1629 switch (delegate_state_) { 1640 switch (delegate_state_) {
1630 case DelegateState::GONE: 1641 case DelegateState::GONE:
1631 delegate_->PlayerGone(delegate_id_); 1642 delegate_->PlayerGone(delegate_id_);
1632 break; 1643 break;
1633 case DelegateState::PLAYING: 1644 case DelegateState::PLAYING: {
1645 autoplay_muted_ = client_->isAutoplayingMuted();
1646 bool has_audio = autoplay_muted_ ? false : hasAudio();
1634 delegate_->DidPlay( 1647 delegate_->DidPlay(
1635 delegate_id_, hasVideo(), hasAudio(), false, 1648 delegate_id_, hasVideo(), has_audio, false,
1636 media::DurationToMediaContentType(pipeline_.GetMediaDuration())); 1649 media::DurationToMediaContentType(pipeline_.GetMediaDuration()));
1637 break; 1650 break;
1651 }
1638 case DelegateState::PAUSED: 1652 case DelegateState::PAUSED:
1639 delegate_->DidPause(delegate_id_, false); 1653 delegate_->DidPause(delegate_id_, false);
1640 break; 1654 break;
1641 case DelegateState::ENDED: 1655 case DelegateState::ENDED:
1642 delegate_->DidPause(delegate_id_, true); 1656 delegate_->DidPause(delegate_id_, true);
1643 break; 1657 break;
1644 } 1658 }
1645 } 1659 }
1646 1660
1647 void WebMediaPlayerImpl::SetMemoryReportingState( 1661 void WebMediaPlayerImpl::SetMemoryReportingState(
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 pipeline_metadata_.natural_size, 1874 pipeline_metadata_.natural_size,
1861 base::Bind(&GetCurrentTimeInternal, this))); 1875 base::Bind(&GetCurrentTimeInternal, this)));
1862 watch_time_reporter_->OnVolumeChange(volume_); 1876 watch_time_reporter_->OnVolumeChange(volume_);
1863 if (delegate_ && delegate_->IsHidden()) 1877 if (delegate_ && delegate_->IsHidden())
1864 watch_time_reporter_->OnHidden(); 1878 watch_time_reporter_->OnHidden();
1865 else 1879 else
1866 watch_time_reporter_->OnShown(); 1880 watch_time_reporter_->OnShown();
1867 } 1881 }
1868 1882
1869 } // namespace media 1883 } // 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