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

Side by Side Diff: content/browser/media/android/media_session.cc

Issue 1266903002: [MediaSession,Android] Request audio focus if needed when resuming playback from UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "content/browser/media/android/media_session.h" 5 #include "content/browser/media/android/media_session.h"
6 6
7 #include "base/android/jni_android.h" 7 #include "base/android/jni_android.h"
8 #include "content/browser/media/android/media_session_observer.h" 8 #include "content/browser/media/android/media_session_observer.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 if (audio_focus_state_ != State::SUSPENDED) 121 if (audio_focus_state_ != State::SUSPENDED)
122 return; 122 return;
123 123
124 OnResumeInternal(SuspendType::SYSTEM); 124 OnResumeInternal(SuspendType::SYSTEM);
125 UpdateWebContents(); 125 UpdateWebContents();
126 } 126 }
127 127
128 void MediaSession::Resume() { 128 void MediaSession::Resume() {
129 DCHECK(IsSuspended()); 129 DCHECK(IsSuspended());
130 130
131 // Request audio focus again in case we lost it because another app started
132 // playing while the playback was paused.
133 audio_focus_state_ = RequestSystemAudioFocus(audio_focus_type_)
134 ? State::ACTIVE
135 : State::INACTIVE;
136 if (audio_focus_state_ != State::ACTIVE)
137 return;
138
131 OnResumeInternal(SuspendType::UI); 139 OnResumeInternal(SuspendType::UI);
132 } 140 }
133 141
134 void MediaSession::Suspend() { 142 void MediaSession::Suspend() {
135 DCHECK(!IsSuspended()); 143 DCHECK(!IsSuspended());
136 144
137 OnSuspendInternal(SuspendType::UI); 145 OnSuspendInternal(SuspendType::UI);
138 } 146 }
139 147
140 bool MediaSession::IsSuspended() const { 148 bool MediaSession::IsSuspended() const {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 229
222 audio_focus_state_ = State::INACTIVE; 230 audio_focus_state_ = State::INACTIVE;
223 UpdateWebContents(); 231 UpdateWebContents();
224 } 232 }
225 233
226 void MediaSession::UpdateWebContents() { 234 void MediaSession::UpdateWebContents() {
227 static_cast<WebContentsImpl*>(web_contents())->OnMediaSessionStateChanged(); 235 static_cast<WebContentsImpl*>(web_contents())->OnMediaSessionStateChanged();
228 } 236 }
229 237
230 } // namespace content 238 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698