mirror of
https://github.com/samsonjs/media.git
synced 2026-04-19 13:35:47 +00:00
Handle stream volume register/unregister errors
Issue: #8106 Issue: #8087 PiperOrigin-RevId: 338664455
This commit is contained in:
parent
da663aa081
commit
1264dbcd36
2 changed files with 32 additions and 11 deletions
|
|
@ -1,5 +1,12 @@
|
|||
# Release notes
|
||||
|
||||
### 2.12.2 (2020-11-??) ###
|
||||
|
||||
* Core library:
|
||||
* 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)).
|
||||
|
||||
### 2.12.1 (2020-10-23) ###
|
||||
|
||||
* Core library:
|
||||
|
|
@ -7,6 +14,7 @@
|
|||
argument ([#8024](https://github.com/google/ExoPlayer/issues/8024)).
|
||||
* Fix bug where streams with highly uneven track durations may get stuck
|
||||
in a buffering state
|
||||
([#7943](https://github.com/google/ExoPlayer/issues/7943)).
|
||||
* Switch Guava dependency from `implementation` to `api`
|
||||
([#7905](https://github.com/google/ExoPlayer/issues/7905),
|
||||
[#7993](https://github.com/google/ExoPlayer/issues/7993)).
|
||||
|
|
@ -63,9 +71,9 @@
|
|||
* Allow apps to specify a `VideoAdPlayerCallback`
|
||||
([#7944](https://github.com/google/ExoPlayer/issues/7944)).
|
||||
* Accept ad tags via the `AdsMediaSource` constructor and deprecate
|
||||
passing them via the `ImaAdsLoader` constructor/builders. Passing the
|
||||
ad tag via media item playback properties continues to be supported.
|
||||
This is in preparation for supporting ads in playlists
|
||||
passing them via the `ImaAdsLoader` constructor/builders. Passing the ad
|
||||
tag via media item playback properties continues to be supported. This
|
||||
is in preparation for supporting ads in playlists
|
||||
([#3750](https://github.com/google/ExoPlayer/issues/3750)).
|
||||
* Add a way to override ad media MIME types
|
||||
([#7961)(https://github.com/google/ExoPlayer/issues/7961)).
|
||||
|
|
@ -74,6 +82,8 @@
|
|||
* Upgrade IMA SDK dependency to 3.20.1. This brings in a fix for
|
||||
companion ads rendering when targeting API 29
|
||||
([#6432](https://github.com/google/ExoPlayer/issues/6432)).
|
||||
* Metadata retriever:
|
||||
* Parse Google Photos HEIC motion photos metadata.
|
||||
|
||||
### 2.12.0 (2020-09-11) ###
|
||||
|
||||
|
|
|
|||
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue