Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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 |
| OLD | NEW |