| 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 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 // playback. The user can still control these players via the MediaSession UI. | 1075 // playback. The user can still control these players via the MediaSession UI. |
| 1076 // If the player has never started playback, OnSuspendRequested() will handle | 1076 // If the player has never started playback, OnSuspendRequested() will handle |
| 1077 // release of any idle resources. | 1077 // release of any idle resources. |
| 1078 if (!hasVideo() && !paused_ && !ended_) | 1078 if (!hasVideo() && !paused_ && !ended_) |
| 1079 return; | 1079 return; |
| 1080 | 1080 |
| 1081 // Always reset the buffering strategy to normal when suspending for hidden to | 1081 // Always reset the buffering strategy to normal when suspending for hidden to |
| 1082 // prevent an idle network connection from lingering. | 1082 // prevent an idle network connection from lingering. |
| 1083 setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal); | 1083 setBufferingStrategy(WebMediaPlayer::BufferingStrategy::Normal); |
| 1084 pipeline_controller_.Suspend(); | 1084 pipeline_controller_.Suspend(); |
| 1085 // If we're in the middle of a suspend/resume cycle we no longer want to |
| 1086 // resume when the suspend completes. |
| 1087 pending_suspend_resume_cycle_ = false; |
| 1085 if (delegate_) | 1088 if (delegate_) |
| 1086 delegate_->PlayerGone(delegate_id_); | 1089 delegate_->PlayerGone(delegate_id_); |
| 1087 } | 1090 } |
| 1088 | 1091 |
| 1089 void WebMediaPlayerImpl::OnShown() { | 1092 void WebMediaPlayerImpl::OnShown() { |
| 1090 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1093 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1091 if (!IsSuspendUponHiddenEnabled()) | 1094 if (!IsSuspendUponHiddenEnabled()) |
| 1092 return; | 1095 return; |
| 1093 | 1096 |
| 1094 #if defined(OS_ANDROID) // WMPI_CAST | 1097 #if defined(OS_ANDROID) // WMPI_CAST |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() { | 1520 bool WebMediaPlayerImpl::IsAutomaticResumeAllowed() { |
| 1518 #if defined(OS_ANDROID) | 1521 #if defined(OS_ANDROID) |
| 1519 return !hasVideo() || (delegate_ && !delegate_->IsHidden()); | 1522 return !hasVideo() || (delegate_ && !delegate_->IsHidden()); |
| 1520 #else | 1523 #else |
| 1521 // On non-Android platforms Resume() is always allowed. | 1524 // On non-Android platforms Resume() is always allowed. |
| 1522 return true; | 1525 return true; |
| 1523 #endif | 1526 #endif |
| 1524 } | 1527 } |
| 1525 | 1528 |
| 1526 } // namespace media | 1529 } // namespace media |
| OLD | NEW |