I've got an android app that listens to music broadcasts. It receives track change notifications using the following ApplicationManifest.xml (snippet):
<receiver android:name=".music.AndroidMusicBroadcastReceiver">
<intent-filter>
<action android:name="com.android.music.metachanged"/>
<action android:name="com.android.music.playbackcomplete"/>
<action android:name="com.android.music.playstatechanged"/>
<action android:name="com.htc.music.metachanged"/>
<action android:name="com.htc.music.playbackcomplete"/>
<action android:name="com.htc.music.playstatechanged"/>
</intent-filter>
</receiver>
When I get this broadcast intent from my nexus 4 running the default (builtin) Google Play Music app, the bundle has useful information about the currently playing track, including "artist" and "title". It doesn't have a file path, which I would like. But it does have an "id" field (a long
), which makes me think I can perhaps look up the additional information using that ID as a key. But I can't figure out: What database / content provider is this ID a key into?
Things I've tried so far:
1) I would have expected this to correspond to the _ID field of the content resolver for one of:
- MediaStore.Audio.Media.INTERNAL_CONTENT_URI
- MediaStore.Audio.Media.EXTERNAL_CONTENT_URI
But I've tried querying both of those, and the IDs are nowhere in the same ballpark. My current example is that I'm getting an "id" (in the broadcast) of 3399
. But querying all the tracks in the EXTERNAL_CONTENT_URI gives me IDs in the range of 20865-23051, plus a couple of small IDs (20 and 24, corresponding to a notification and ringtone installed by the google+ app).
For this source, the ID for the currently playing track would be 21373
(I looked up the ID based on the path, which I can figure out by manual inspection).
INTERNAL_CONTENT_URI just gives me builtin stuff (like ringtones, etc) - all the IDs are < 100, so that's not useful either.
2) I did the same query against all media objects - using MediaStore.Files.getContentUri("external")
. I got back plenty of results, but ID 3399
is a random file cached by newsrob (an RSS reader), so that's clearly not relevant.