Workaround of AudioEffect crashing on Lenovo tablets (#7309)

Android 14 on Lenovo tablets does not intialize this AudioEffect. Catch this exception and continue playback.
This commit is contained in:
Gregory Simon 2024-08-01 13:06:49 -07:00 committed by GitHub
parent be3ad792b6
commit 627d8ee83f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 5 deletions

View File

@ -274,14 +274,22 @@ public class ExoPlayerWrapper {
public void setVolume(float v, float v1) {
if (v > 1) {
exoPlayer.setVolume(1f);
if (loudnessEnhancer != null) {
loudnessEnhancer.setEnabled(true);
loudnessEnhancer.setTargetGain((int) (1000 * (v - 1)));
try {
if (loudnessEnhancer != null) {
loudnessEnhancer.setEnabled(true);
loudnessEnhancer.setTargetGain((int) (1000 * (v - 1)));
}
} catch (Exception e) {
Log.d(TAG, e.toString());
}
} else {
exoPlayer.setVolume(v);
if (loudnessEnhancer != null) {
loudnessEnhancer.setEnabled(false);
try {
if (loudnessEnhancer != null) {
loudnessEnhancer.setEnabled(false);
}
} catch (Exception e) {
Log.d(TAG, e.toString());
}
}
}