fix: set no replay gain if array is null or empty

This commit is contained in:
antonio 2023-09-13 17:27:43 +02:00
parent 16561be854
commit a50e50d797

View file

@ -1,7 +1,5 @@
package com.cappielloantonio.tempo.util;
import android.util.Log;
import androidx.annotation.OptIn;
import androidx.media3.common.MediaItem;
import androidx.media3.common.Metadata;
@ -17,8 +15,6 @@ import java.util.Objects;
@OptIn(markerClass = UnstableApi.class)
public class ReplayGainUtil {
private static final String TAG = "ReplayGainUtil";
private static final String[] tags = {"REPLAYGAIN_TRACK_GAIN", "REPLAYGAIN_ALBUM_GAIN", "R128_TRACK_GAIN", "R128_ALBUM_GAIN"};
public static void setReplayGain(ExoPlayer player, Tracks tracks) {
@ -113,6 +109,11 @@ public class ReplayGainUtil {
}
private static void applyReplayGain(ExoPlayer player, List<ReplayGain> gains) {
if (Objects.equals(Preferences.getReplayGainMode(), "disabled") || gains == null || gains.isEmpty()) {
setNoReplayGain(player);
return;
}
if (Objects.equals(Preferences.getReplayGainMode(), "auto")) {
if (areTracksConsecutive(player)) {
setAutoReplayGain(player, gains);
@ -123,11 +124,6 @@ public class ReplayGainUtil {
return;
}
if (Objects.equals(Preferences.getReplayGainMode(), "disabled") || gains.size() == 0) {
setNoReplayGain(player);
return;
}
if (Objects.equals(Preferences.getReplayGainMode(), "track")) {
setTrackReplayGain(player, gains);
return;