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
160ee9d8
authored
Oct 23, 2020
by
andrewlewis
Committed by
Oliver Woodman
Nov 02, 2020
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Handle stream volume register/unregister errors
Issue: #8106 Issue: #8087 PiperOrigin-RevId: 338664455
parent
a1849243
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
8 deletions
RELEASENOTES.md
library/core/src/main/java/com/google/android/exoplayer2/StreamVolumeManager.java
RELEASENOTES.md
View file @
160ee9d8
...
...
@@ -18,6 +18,9 @@
(
[
#5887
](
https://github.com/google/ExoPlayer/issues/5887
)
).
*
Fix bug where
`AnalyticsListener`
callbacks can arrive in the wrong
order (
[
#8048
](
https://github.com/google/ExoPlayer/issues/8048
)
).
*
Suppress exceptions from registering/unregistering the stream volume
receiver (
[
#8087
](
https://github.com/google/ExoPlayer/issues/8087
)
),
(
[
#8106
](
https://github.com/google/ExoPlayer/issues/8106
)
).
*
Track selection:
*
Add option to specify multiple preferred audio or text languages.
*
UI:
...
...
library/core/src/main/java/com/google/android/exoplayer2/StreamVolumeManager.java
View file @
160ee9d8
...
...
@@ -21,7 +21,9 @@ import android.content.Intent;
import
android.content.IntentFilter
;
import
android.media.AudioManager
;
import
android.os.Handler
;
import
androidx.annotation.Nullable
;
import
com.google.android.exoplayer2.util.Assertions
;
import
com.google.android.exoplayer2.util.Log
;
import
com.google.android.exoplayer2.util.Util
;
/** A manager that wraps {@link AudioManager} to control/listen audio stream volume. */
...
...
@@ -37,6 +39,8 @@ import com.google.android.exoplayer2.util.Util;
void
onStreamVolumeChanged
(
int
streamVolume
,
boolean
streamMuted
);
}
private
static
final
String
TAG
=
"StreamVolumeManager"
;
// TODO(b/151280453): Replace the hidden intent action with an official one.
// Copied from AudioManager#VOLUME_CHANGED_ACTION
private
static
final
String
VOLUME_CHANGED_ACTION
=
"android.media.VOLUME_CHANGED_ACTION"
;
...
...
@@ -48,12 +52,11 @@ import com.google.android.exoplayer2.util.Util;
private
final
Handler
eventHandler
;
private
final
Listener
listener
;
private
final
AudioManager
audioManager
;
private
final
VolumeChangeReceiver
receiver
;
@Nullable
private
VolumeChangeReceiver
receiver
;
@C
.
StreamType
private
int
streamType
;
private
int
volume
;
private
boolean
muted
;
private
boolean
released
;
/** Creates a manager. */
public
StreamVolumeManager
(
Context
context
,
Handler
eventHandler
,
Listener
listener
)
{
...
...
@@ -68,9 +71,14 @@ import com.google.android.exoplayer2.util.Util;
volume
=
getVolumeFromManager
(
audioManager
,
streamType
);
muted
=
getMutedFromManager
(
audioManager
,
streamType
);
receiver
=
new
VolumeChangeReceiver
();
VolumeChangeReceiver
receiver
=
new
VolumeChangeReceiver
();
IntentFilter
filter
=
new
IntentFilter
(
VOLUME_CHANGED_ACTION
);
applicationContext
.
registerReceiver
(
receiver
,
filter
);
try
{
applicationContext
.
registerReceiver
(
receiver
,
filter
);
this
.
receiver
=
receiver
;
}
catch
(
RuntimeException
e
)
{
Log
.
w
(
TAG
,
"Error registering stream volume receiver"
,
e
);
}
}
/** Sets the audio stream type. */
...
...
@@ -159,11 +167,14 @@ import com.google.android.exoplayer2.util.Util;
/** Releases the manager. It must be called when the manager is no longer required. */
public
void
release
()
{
if
(
released
)
{
return
;
if
(
receiver
!=
null
)
{
try
{
applicationContext
.
unregisterReceiver
(
receiver
);
}
catch
(
RuntimeException
e
)
{
Log
.
w
(
TAG
,
"Error unregistering stream volume receiver"
,
e
);
}
receiver
=
null
;
}
applicationContext
.
unregisterReceiver
(
receiver
);
released
=
true
;
}
private
void
updateVolumeAndNotifyIfChanged
()
{
...
...
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