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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 887c99eba4c968c1746105295a0f9c856fd38265..c0fad2da254ec7e0044b6d8570aba6fad1b40705 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -533,6 +533,10 @@ void WebMediaPlayerImpl::setVolume(double volume) {
pipeline_.SetVolume(volume_ * volume_multiplier_);
if (watch_time_reporter_)
watch_time_reporter_->OnVolumeChange(volume);
+
+ // The play state is updated because the player might have left the autoplay
+ // muted state.
+ UpdatePlayState();
}
void WebMediaPlayerImpl::setSinkId(
@@ -1621,20 +1625,30 @@ void WebMediaPlayerImpl::UpdatePlayState() {
}
void WebMediaPlayerImpl::SetDelegateState(DelegateState new_state) {
- if (!delegate_ || delegate_state_ == new_state)
+ if (!delegate_)
return;
+ if (delegate_state_ == new_state) {
+ if (delegate_state_ != DelegateState::PLAYING ||
+ autoplay_muted_ == client_->isAutoplayingMuted()) {
+ return;
+ }
+ }
+
delegate_state_ = new_state;
switch (delegate_state_) {
case DelegateState::GONE:
delegate_->PlayerGone(delegate_id_);
break;
- case DelegateState::PLAYING:
+ case DelegateState::PLAYING: {
+ autoplay_muted_ = client_->isAutoplayingMuted();
+ bool has_audio = autoplay_muted_ ? false : hasAudio();
delegate_->DidPlay(
- delegate_id_, hasVideo(), hasAudio(), false,
+ delegate_id_, hasVideo(), has_audio, false,
media::DurationToMediaContentType(pipeline_.GetMediaDuration()));
break;
+ }
case DelegateState::PAUSED:
delegate_->DidPause(delegate_id_, false);
break;
« 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