1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-11-17 07:29:27 +01:00
Gadgetbridge/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/externalevents/MusicPlaybackReceiver.java

32 lines
1.2 KiB
Java
Raw Normal View History

package nodomain.freeyourgadget.gadgetbridge.externalevents;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import nodomain.freeyourgadget.gadgetbridge.GBApplication;
import nodomain.freeyourgadget.gadgetbridge.model.MusicSpec;
public class MusicPlaybackReceiver extends BroadcastReceiver {
private static final Logger LOG = LoggerFactory.getLogger(MusicPlaybackReceiver.class);
private static MusicSpec lastMusicSpec = new MusicSpec();
@Override
public void onReceive(Context context, Intent intent) {
MusicSpec musicSpec = new MusicSpec();
musicSpec.artist = intent.getStringExtra("artist");
musicSpec.album = intent.getStringExtra("album");
musicSpec.track = intent.getStringExtra("track");
if (!lastMusicSpec.equals(musicSpec)) {
lastMusicSpec = musicSpec;
LOG.info("Update Music Info: " + musicSpec.artist + " / " + musicSpec.album + " / " + musicSpec.track);
GBApplication.deviceService().onSetMusicInfo(musicSpec);
} else {
LOG.info("got metadata changed intent, but nothing changed, ignoring.");
}
}
}