Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
a02a75ba
authored
Nov 07, 2018
by
Oliver Woodman
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Fix audio focus
parent
f5c3b302
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
12 deletions
library/core/src/main/java/com/google/android/exoplayer2/audio/AudioFocusManager.java
library/core/src/test/java/com/google/android/exoplayer2/audio/AudioFocusManagerTest.java
library/core/src/main/java/com/google/android/exoplayer2/audio/AudioFocusManager.java
View file @
a02a75ba
...
...
@@ -163,11 +163,9 @@ public final class AudioFocusManager {
}
}
if
(
playerState
==
Player
.
STATE_IDLE
)
{
return
PLAYER_COMMAND_WAIT_FOR_CALLBACK
;
}
else
{
return
handlePrepare
(
playWhenReady
);
}
return
playerState
==
Player
.
STATE_IDLE
?
handleIdle
(
playWhenReady
)
:
handlePrepare
(
playWhenReady
);
}
/**
...
...
@@ -199,12 +197,9 @@ public final class AudioFocusManager {
if
(!
playWhenReady
)
{
abandonAudioFocus
();
return
PLAYER_COMMAND_DO_NOT_PLAY
;
}
else
if
(
playerState
!=
Player
.
STATE_IDLE
)
{
return
requestAudioFocus
();
}
return
focusGain
!=
C
.
AUDIOFOCUS_NONE
?
PLAYER_COMMAND_WAIT_FOR_CALLBACK
:
PLAYER_COMMAND_PLAY_WHEN_READY
;
return
playerState
==
Player
.
STATE_IDLE
?
handleIdle
(
playWhenReady
)
:
requestAudioFocus
();
}
/** Called by the player as part of {@link ExoPlayer#stop(boolean)}. */
...
...
@@ -218,6 +213,11 @@ public final class AudioFocusManager {
// Internal methods.
@PlayerCommand
private
int
handleIdle
(
boolean
playWhenReady
)
{
return
playWhenReady
?
PLAYER_COMMAND_PLAY_WHEN_READY
:
PLAYER_COMMAND_DO_NOT_PLAY
;
}
private
@PlayerCommand
int
requestAudioFocus
()
{
int
focusRequestResult
;
...
...
library/core/src/test/java/com/google/android/exoplayer2/audio/AudioFocusManagerTest.java
View file @
a02a75ba
...
...
@@ -58,7 +58,7 @@ public class AudioFocusManagerTest {
assertThat
(
audioFocusManager
.
setAudioAttributes
(
/* audioAttributes= */
null
,
/* playWhenReady= */
false
,
Player
.
STATE_IDLE
))
.
isEqualTo
(
PLAYER_COMMAND_
WAIT_FOR_CALLBACK
);
.
isEqualTo
(
PLAYER_COMMAND_
DO_NOT_PLAY
);
assertThat
(
audioFocusManager
.
setAudioAttributes
(
/* audioAttributes= */
null
,
/* playWhenReady= */
true
,
Player
.
STATE_READY
))
...
...
@@ -148,7 +148,7 @@ public class AudioFocusManagerTest {
assertThat
(
audioFocusManager
.
setAudioAttributes
(
media
,
/* playWhenReady= */
true
,
Player
.
STATE_IDLE
))
.
isEqualTo
(
PLAYER_COMMAND_
WAIT_FOR_CALLBACK
);
.
isEqualTo
(
PLAYER_COMMAND_
PLAY_WHEN_READY
);
assertThat
(
Shadows
.
shadowOf
(
audioManager
).
getLastAudioFocusRequest
()).
isNull
();
assertThat
(
audioFocusManager
.
handlePrepare
(
/* playWhenReady= */
true
))
.
isEqualTo
(
PLAYER_COMMAND_PLAY_WHEN_READY
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment