我使用内容提供者 URI content://com.google.android.music.MusicContent/audio和以下代码获取条目列表(在设备上和离线) :
String[] proj = { MediaStore.Audio.AudioColumns.TITLE, MediaStore.Audio.Media.ARTIST, MediaStore.Audio.Media._ID };
Uri gMusicUri = Uri.parse("content://com.google.android.music.MusicContent/audio");
Ln.d("onCreate(): XX gMusicUri = %s", gMusicUri);
Cursor cursor = getApplicationContext().getContentResolver().query(gMusicUri, proj, null, null, null);
if (cursor == null) {
// query failed, handle error.
Ln.w("onCreate(): XX cursor is null, query failed");
} else if (!cursor.moveToFirst()) {
// no media on the device
Ln.w("onCreate(): XX cursor cannot move to 1st element, no media on device");
} else {
int idColumn = cursor.getColumnIndex(MediaStore.Audio.Media._ID);
int titleColumn = cursor.getColumnIndex(MediaStore.Audio.Media.TITLE);
int artistColumn = cursor.getColumnIndex(MediaStore.Audio.Media.ARTIST);
do {
long id = cursor.getLong(idColumn);
String title = cursor.getString(titleColumn);
String artist = cursor.getString(artistColumn);
// ...process entry...
Ln.i("onCreate(): XX id = %d, title = %s, artist = %s", id, title, artist);
} while (cursor.moveToNext());
}
cursor.close();
我需要流媒体,想知道这是否可能?!