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

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

Issue 2449873006: Don't background pause suspend until we have future data. (Closed)
Patch Set: Add tests. 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
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 1738 matching lines...) Expand 10 before | Expand all | Expand 10 after
1749 // though in the case of audio-only the session should be kept. 1749 // though in the case of audio-only the session should be kept.
1750 // Videos are not suspended if the user resumed the playback via the remote 1750 // Videos are not suspended if the user resumed the playback via the remote
1751 // controls earlier and it's still playing. 1751 // controls earlier and it's still playing.
1752 bool is_backgrounded_video = is_backgrounded && have_metadata && hasVideo(); 1752 bool is_backgrounded_video = is_backgrounded && have_metadata && hasVideo();
1753 bool can_play_backgrounded = is_backgrounded_video && !is_remote && 1753 bool can_play_backgrounded = is_backgrounded_video && !is_remote &&
1754 hasAudio() && IsResumeBackgroundVideosEnabled(); 1754 hasAudio() && IsResumeBackgroundVideosEnabled();
1755 bool is_background_playing = 1755 bool is_background_playing =
1756 delegate_ && delegate_->IsPlayingBackgroundVideo(); 1756 delegate_ && delegate_->IsPlayingBackgroundVideo();
1757 bool background_suspended = is_backgrounded_video && 1757 bool background_suspended = is_backgrounded_video &&
1758 !(can_play_backgrounded && is_background_playing); 1758 !(can_play_backgrounded && is_background_playing);
1759 bool background_pause_suspended = is_backgrounded && paused_; 1759 // Only suspend for pause in the background if we have future data, otherwise
1760 // we may miss out on legitimate background playback attempts.
sandersd (OOO until July 31) 2016/10/26 23:07:46 The comment is slightly confusing since we can sti
DaleCurtis 2016/10/27 00:36:39 Reworded.
1761 bool background_pause_suspended =
1762 is_backgrounded && paused_ && have_future_data;
1760 1763
1761 // TODO(sandersd): Make the delegate suspend idle players immediately when 1764 // TODO(sandersd): Make the delegate suspend idle players immediately when
1762 // hidden. 1765 // hidden.
1763 bool idle_suspended = is_idle_ && paused_ && !seeking_ && !overlay_enabled_; 1766 bool idle_suspended = is_idle_ && paused_ && !seeking_ && !overlay_enabled_;
1764 1767
1765 // If we're already suspended, see if we can wait for user interaction. Prior 1768 // If we're already suspended, see if we can wait for user interaction. Prior
1766 // to HaveFutureData, we require |is_idle_| to remain suspended. |is_idle_| 1769 // to HaveFutureData, we require |is_idle_| to remain suspended. |is_idle_|
1767 // will be cleared when we receive data which may take us to HaveFutureData. 1770 // will be cleared when we receive data which may take us to HaveFutureData.
1768 bool can_stay_suspended = 1771 bool can_stay_suspended =
1769 (is_idle_ || have_future_data) && is_suspended && paused_ && !seeking_; 1772 (is_idle_ || have_future_data) && is_suspended && paused_ && !seeking_;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1884 pipeline_metadata_.natural_size, 1887 pipeline_metadata_.natural_size,
1885 base::Bind(&GetCurrentTimeInternal, this))); 1888 base::Bind(&GetCurrentTimeInternal, this)));
1886 watch_time_reporter_->OnVolumeChange(volume_); 1889 watch_time_reporter_->OnVolumeChange(volume_);
1887 if (delegate_ && delegate_->IsHidden()) 1890 if (delegate_ && delegate_->IsHidden())
1888 watch_time_reporter_->OnHidden(); 1891 watch_time_reporter_->OnHidden();
1889 else 1892 else
1890 watch_time_reporter_->OnShown(); 1893 watch_time_reporter_->OnShown();
1891 } 1894 }
1892 1895
1893 } // namespace media 1896 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('j') | media/blink/webmediaplayer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698