Eleven: Implement onPlayFromMediaId()
This is invoked by Android Auto if any playable media item
is selected.
Change-Id: Id151ebb31baa7f94e6f2020fb123b72a3ecf95b1
diff --git a/src/org/lineageos/eleven/MusicPlaybackService.java b/src/org/lineageos/eleven/MusicPlaybackService.java
index 5427a77..bf23894 100644
--- a/src/org/lineageos/eleven/MusicPlaybackService.java
+++ b/src/org/lineageos/eleven/MusicPlaybackService.java
@@ -826,6 +826,14 @@
}
return super.onMediaButtonEvent(mediaButtonIntent);
}
+
+ @Override
+ public void onPlayFromMediaId(String mediaId, Bundle extras) {
+ int position = mSongs.indexOf(Long.parseLong(mediaId));
+ // TODO: Detect when played from playlist, album, or artist
+ open(mSongs.stream().mapToLong(i -> i).toArray(), position, -1, IdType.NA);
+ onPlay();
+ }
});
PendingIntent pi = PendingIntent.getBroadcast(this, 0,