本文整理汇总了Java中android.provider.MediaStore.Audio.AudioColumns.ARTIST_ID属性的典型用法代码示例。如果您正苦于以下问题:Java AudioColumns.ARTIST_ID属性的具体用法?Java AudioColumns.ARTIST_ID怎么用?Java AudioColumns.ARTIST_ID使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.provider.MediaStore.Audio.AudioColumns
的用法示例。
在下文中一共展示了AudioColumns.ARTIST_ID属性的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSongListForArtist
/**
* @param context The {@link Context} to use.
* @param id The ID of the artist.
* @return The song list for an artist.
*/
public static final long[] getSongListForArtist(final Context context, final long id) {
final String[] projection = new String[]{
BaseColumns._ID
};
final String selection = AudioColumns.ARTIST_ID + "=" + id + " AND "
+ AudioColumns.IS_MUSIC + "=1";
Cursor cursor = context.getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
AudioColumns.ALBUM_KEY + "," + AudioColumns.TRACK);
if (cursor != null) {
final long[] mList = getSongListForCursor(cursor);
cursor.close();
cursor = null;
return mList;
}
return sEmptyList;
}
示例2: getSongListForArtist
/**
* @param context
* @param id
* @return
*/
public static long[] getSongListForArtist(Context context, long id) {
final String[] projection = new String[] {
BaseColumns._ID
};
String selection = AudioColumns.ARTIST_ID + "=" + id + " AND " + AudioColumns.IS_MUSIC
+ "=1";
String sortOrder = AudioColumns.ALBUM_KEY + "," + AudioColumns.TRACK;
Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
Cursor cursor = query(context, uri, projection, selection, null, sortOrder);
if (cursor != null) {
long[] list = getSongListForCursor(cursor);
cursor.close();
return list;
}
return sEmptyList;
}
示例3: getSongListForArtist
/**
* @param context The {@link Context} to use.
* @param id The ID of the artist.
* @return The song list for an artist.
*/
public static final long[] getSongListForArtist(final Context context, final String id) {
final String[] projection = new String[] {
BaseColumns._ID
};
final String selection = AudioColumns.ARTIST_ID + "=" + id + " AND "
+ AudioColumns.IS_MUSIC + "=1";
Cursor cursor = context.getContentResolver().query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
AudioColumns.ALBUM_KEY + "," + AudioColumns.TRACK);
if (cursor != null) {
final long[] mList = getSongListForCursor(cursor);
cursor.close();
cursor = null;
return mList;
}
return sEmptyList;
}
示例4: reloadQueueCursor
/**
* Reload the queue after we remove a track
*/
private void reloadQueueCursor() {
if (mPlaylistId == PLAYLIST_QUEUE) {
String[] cols = new String[] {
BaseColumns._ID, MediaColumns.TITLE, MediaColumns.DATA, AudioColumns.ALBUM,
AudioColumns.ARTIST, AudioColumns.ARTIST_ID
};
StringBuilder selection = new StringBuilder();
selection.append(AudioColumns.IS_MUSIC + "=1");
selection.append(" AND " + MediaColumns.TITLE + " != ''");
Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
long[] mNowPlaying = MusicUtils.getQueue();
if (mNowPlaying.length == 0) {
}
selection = new StringBuilder();
selection.append(BaseColumns._ID + " IN (");
for (int i = 0; i < mNowPlaying.length; i++) {
selection.append(mNowPlaying[i]);
if (i < mNowPlaying.length - 1) {
selection.append(",");
}
}
selection.append(")");
mCursor = MusicUtils.query(getActivity(), uri, cols, selection.toString(), null, null);
mTrackAdapter.changeCursor(mCursor);
}
}
示例5: reloadQueueCursor
/**
* Reload the queue after we remove a track
*/
private void reloadQueueCursor() {
String[] cols = new String[] {
BaseColumns._ID, MediaColumns.TITLE, MediaColumns.DATA, AudioColumns.ALBUM,
AudioColumns.ARTIST, AudioColumns.ARTIST_ID
};
StringBuilder selection = new StringBuilder();
selection.append(AudioColumns.IS_MUSIC + "=1");
selection.append(" AND " + MediaColumns.TITLE + " != ''");
Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
long[] mNowPlaying = MusicUtils.getQueue();
if (mNowPlaying.length == 0) {
}
selection = new StringBuilder();
selection.append(BaseColumns._ID + " IN (");
for (int i = 0; i < mNowPlaying.length; i++) {
selection.append(mNowPlaying[i]);
if (i < mNowPlaying.length - 1) {
selection.append(",");
}
}
selection.append(")");
if(mCursor != null)
mCursor.close();
mCursor = MusicUtils.query(getActivity(), uri, cols, selection.toString(), null, null);
String[] audioCols = new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ARTIST, AudioColumns.ALBUM};
MatrixCursor playlistCursor = new MatrixCursor(audioCols);
for(int i = 0; i < mNowPlaying.length; i++){
mCursor.moveToPosition(-1);
while (mCursor.moveToNext()) {
long audioid = mCursor.getLong(mCursor.getColumnIndexOrThrow(BaseColumns._ID));
if( audioid == mNowPlaying[i]) {
String trackName = mCursor.getString(mCursor.getColumnIndexOrThrow(MediaColumns.TITLE));
String artistName = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ARTIST));
String albumName = mCursor.getString(mCursor.getColumnIndexOrThrow(AudioColumns.ALBUM));
playlistCursor.addRow(new Object[] {audioid, trackName, artistName ,albumName});
}
}
}
if(mCursor != null)
mCursor.close();
mCursor = playlistCursor;
mAdapter.changeCursor(playlistCursor);
}