mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
MusicManager: Fix NPE when music not playing
This commit is contained in:
parent
a53d59f907
commit
b0ff9eae88
@ -24,6 +24,8 @@ import android.media.session.MediaController;
|
|||||||
import android.media.session.MediaSessionManager;
|
import android.media.session.MediaSessionManager;
|
||||||
import android.media.session.PlaybackState;
|
import android.media.session.PlaybackState;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
@ -105,7 +107,12 @@ public class MediaManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static MusicSpec extractMusicSpec(final MediaMetadata d) {
|
public static MusicSpec extractMusicSpec(final MediaMetadata d) {
|
||||||
|
if (d == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final MusicSpec musicSpec = new MusicSpec();
|
final MusicSpec musicSpec = new MusicSpec();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -128,7 +135,12 @@ public class MediaManager {
|
|||||||
return musicSpec;
|
return musicSpec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public static MusicStateSpec extractMusicStateSpec(final PlaybackState s) {
|
public static MusicStateSpec extractMusicStateSpec(final PlaybackState s) {
|
||||||
|
if (s == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
final MusicStateSpec stateSpec = new MusicStateSpec();
|
final MusicStateSpec stateSpec = new MusicStateSpec();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user