当前位置: 首页>>代码示例>>Java>>正文


Java AudioColumns类代码示例

本文整理汇总了Java中android.provider.MediaStore.Audio.AudioColumns的典型用法代码示例。如果您正苦于以下问题:Java AudioColumns类的具体用法?Java AudioColumns怎么用?Java AudioColumns使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


AudioColumns类属于android.provider.MediaStore.Audio包,在下文中一共展示了AudioColumns类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: makePlaylistSongCursor

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
public static Cursor makePlaylistSongCursor(@NonNull final Context context, final int playlistId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Playlists.Members.getContentUri("external", playlistId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                        MediaStore.Audio.Playlists.Members._ID // 11
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
开发者ID:aliumujib,项目名称:Orin,代码行数:24,代码来源:PlaylistSongLoader.java

示例2: makeLastAddedCursor

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
public static final Cursor makeLastAddedCursor(final Context context) {
    //four weeks ago
    long fourWeeksAgo = (System.currentTimeMillis() / 1000) - (4 * 3600 * 24 * 7);
    long cutoff = PreferencesUtility.getInstance(context).getLastAddedCutoff();
    // use the most recent of the two timestamps
    if (cutoff < fourWeeksAgo) {
        cutoff = fourWeeksAgo;
    }

    final StringBuilder selection = new StringBuilder();
    selection.append(AudioColumns.IS_MUSIC + "=1");
    selection.append(" AND " + AudioColumns.TITLE + " != ''");
    selection.append(" AND " + MediaStore.Audio.Media.DATE_ADDED + ">");
    selection.append(cutoff);

    return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            new String[]{"_id", "title", "artist", "album", "duration", "track", "artist_id", "album_id"}, selection.toString(), null, MediaStore.Audio.Media.DATE_ADDED + " DESC");
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:19,代码来源:LastAddedLoader.java

示例3: makePlaylistSongCursor

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
public static final Cursor makePlaylistSongCursor(final Context context, final Long playlistID) {
    final StringBuilder mSelection = new StringBuilder();
    mSelection.append(AudioColumns.IS_MUSIC + "=1");
    mSelection.append(" AND " + AudioColumns.TITLE + " != ''");
    return context.getContentResolver().query(
            MediaStore.Audio.Playlists.Members.getContentUri("external", playlistID),
            new String[]{
                    MediaStore.Audio.Playlists.Members._ID,
                    MediaStore.Audio.Playlists.Members.AUDIO_ID,
                    AudioColumns.TITLE,
                    AudioColumns.ARTIST,
                    AudioColumns.ALBUM_ID,
                    AudioColumns.ARTIST_ID,
                    AudioColumns.ALBUM,
                    AudioColumns.DURATION,
                    AudioColumns.TRACK,
                    Playlists.Members.PLAY_ORDER,
            }, mSelection.toString(), null,
            MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:21,代码来源:PlaylistSongLoader.java

示例4: getSongListForArtist

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
/**
 * @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;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:23,代码来源:MusicUtils.java

示例5: getSongListForAlbum

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The ID of the album.
 * @return The song list for an album.
 */
public static final long[] getSongListForAlbum(final Context context, final long id) {
    final String[] projection = new String[]{
            BaseColumns._ID
    };
    final String selection = AudioColumns.ALBUM_ID + "=" + id + " AND " + AudioColumns.IS_MUSIC
            + "=1";
    Cursor cursor = context.getContentResolver().query(
            MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, projection, selection, null,
            AudioColumns.TRACK + ", " + MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    if (cursor != null) {
        final long[] mList = getSongListForCursor(cursor);
        cursor.close();
        cursor = null;
        return mList;
    }
    return sEmptyList;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:23,代码来源:MusicUtils.java

示例6: getSongListForGenre

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
/**
 * @param context The {@link Context} to use.
 * @param id      The ID of the genre.
 * @return The song list for an genre.
 */
public static final long[] getSongListForGenre(final Context context, final long id) {
    final String[] projection = new String[]{
            BaseColumns._ID
    };
    String selection = (AudioColumns.IS_MUSIC + "=1") +
            " AND " + MediaColumns.TITLE + "!=''";
    final Uri uri = MediaStore.Audio.Genres.Members.getContentUri("external", Long.valueOf(id));
    Cursor cursor = context.getContentResolver().query(uri, projection, selection,
            null, null);
    if (cursor != null) {
        final long[] mList = getSongListForCursor(cursor);
        cursor.close();
        cursor = null;
        return mList;
    }
    return sEmptyList;
}
 
开发者ID:komamj,项目名称:KomaMusic,代码行数:23,代码来源:MusicUtils.java

示例7: makeGenreSongCursor

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
private static Cursor makeGenreSongCursor(Context context, long genreId) {
    try {
        return context.getContentResolver().query(
                MediaStore.Audio.Genres.Members.getContentUri("external", genreId),
                new String[]{
                        MediaStore.Audio.Playlists.Members.AUDIO_ID,// 0
                        AudioColumns.TITLE,// 1
                        AudioColumns.TRACK,// 2
                        AudioColumns.YEAR,// 3
                        AudioColumns.DURATION,// 4
                        AudioColumns.DATA,// 5
                        AudioColumns.DATE_MODIFIED,// 6
                        AudioColumns.ALBUM_ID,// 7
                        AudioColumns.ALBUM,// 8
                        AudioColumns.ARTIST_ID,// 9
                        AudioColumns.ARTIST,// 10
                }, SongLoader.BASE_SELECTION, null,
                MediaStore.Audio.Genres.Members.DEFAULT_SORT_ORDER);
    } catch (SecurityException e) {
        return null;
    }
}
 
开发者ID:h4h13,项目名称:RetroMusicPlayer,代码行数:23,代码来源:GenreSongsLoader.java

示例8: makeLastAddedCursor

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
public static final Cursor makeLastAddedCursor(final Context context) {
    //four weeks ago
    long fourWeeksAgo = (System.currentTimeMillis() / 1000) - (4 * 3600 * 24 * 7);
    long cutoff = 0L;
    // use the most recent of the two timestamps
    if (cutoff < fourWeeksAgo) {
        cutoff = fourWeeksAgo;
    }

    final StringBuilder selection = new StringBuilder();
    selection.append(AudioColumns.IS_MUSIC + "=1");
    selection.append(" AND " + AudioColumns.TITLE + " != ''");
    selection.append(" AND " + MediaStore.Audio.Media.DATE_ADDED + ">");
    selection.append(cutoff);

    return context.getContentResolver().query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
            new String[]{"_id", "title", "artist", "album", "duration", "track", "artist_id", "album_id"}, selection.toString(), null, MediaStore.Audio.Media.DATE_ADDED + " DESC");
}
 
开发者ID:rohanoid5,项目名称:Muzesto,代码行数:19,代码来源:LastAddedLoader.java

示例9: getMp3List

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
public static List<Playlist> getMp3List(Context context) {
    List<Playlist> list = new ArrayList<Playlist>();

    Cursor cursor = new ResolverSer().getResolverSer().getResover(context).query(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, media_info, "",
            null, MediaStore.Audio.Media.DEFAULT_SORT_ORDER);
    if (cursor != null && cursor.getCount() == 0) {
        final AlertDialog xfdialog = new AlertDialog.Builder(context).setTitle("Tips:").setMessage(context.getResources().getString(R.string.music_no_one)).setPositiveButton(context.getResources().getString(R.string.is_positive), null).create();
        xfdialog.show();
        cursor.close();
        return null;
    }
    while (cursor.moveToNext()) {
        int id = cursor.getInt(cursor.getColumnIndex(BaseColumns._ID));
        int album_id = cursor.getInt(cursor.getColumnIndex(AudioColumns.ALBUM_ID));
        String title = cursor.getString(cursor.getColumnIndex(MediaColumns.TITLE));
        String artist = cursor.getString(cursor.getColumnIndex(AudioColumns.ARTIST));
        int duration = cursor.getInt(cursor.getColumnIndex(AudioColumns.DURATION));
        if (duration > 30000) {
            Playlist playlist = new Playlist(id, title, duration, artist, album_id);
            list.add(playlist);
        }
    }
    cursor.close();
    return list;
}
 
开发者ID:Alex-Jerry,项目名称:LLApp,代码行数:26,代码来源:MusicUtil.java

示例10: makeAutoShuffleList

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
private boolean makeAutoShuffleList() {
    ContentResolver res = getContentResolver();
    Cursor c = null;
    try {
        c = res.query(Audio.Media.EXTERNAL_CONTENT_URI, new String[] {
            BaseColumns._ID
        }, AudioColumns.IS_MUSIC + "=1", null, null);
        if (c == null || c.getCount() == 0) {
            return false;
        }
        int len = c.getCount();
        long[] list = new long[len];
        for (int i = 0; i < len; i++) {
            c.moveToNext();
            list[i] = c.getLong(0);
        }
        mAutoShuffleList = list;
        return true;
    } catch (RuntimeException ex) {
    } finally {
        if (c != null) {
            c.close();
        }
    }
    return false;
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:27,代码来源:ApolloService.java

示例11: onCreateLoader

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
@Override
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
	String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return null;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return null;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");
	
    return new AddIdCursorLoader(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:26,代码来源:QuickQueueFragment.java

示例12: reloadQueueCursor

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
/**
 * Reload the queue after we remove a track
 */
private void reloadQueueCursor() {
    String[] projection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST,
    };
    StringBuilder selection = new StringBuilder();
    Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
    String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
    uri = Audio.Media.EXTERNAL_CONTENT_URI;
    long[] mNowPlaying = MusicUtils.getQueue();
    if (mNowPlaying.length == 0)
        return;
    selection = new StringBuilder();
    selection.append(BaseColumns._ID + " IN (");
    if (mNowPlaying == null || mNowPlaying.length <= 0)
        return;
    for (long queue_id : mNowPlaying) {
        selection.append(queue_id + ",");
    }
    selection.deleteCharAt(selection.length() - 1);
    selection.append(")");

    mCursor = MusicUtils.query(getActivity(), uri, projection, selection.toString(), null,
            sortOrder);
    mQuickQueueAdapter.changeCursor(mCursor);
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:29,代码来源:QuickQueueFragment.java

示例13: setupFragmentData

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
@Override
public void setupFragmentData() {
       mAdapter = new AlbumListAdapter(getActivity(), R.layout.music_listview_items, null,
               								new String[] {}, new int[] {}, 0);
   	mProjection = new String[] {
               BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
       };
       StringBuilder where = new StringBuilder();
       where.append(AudioColumns.IS_MUSIC + "=1")
       					.append(" AND " + MediaColumns.TITLE + " != ''");
       long albumId = getArguments().getLong(BaseColumns._ID);
       where.append(" AND " + AudioColumns.ALBUM_ID + "=" + albumId);
       mWhere = where.toString();        
       mSortOrder = Audio.Media.TRACK + ", " + Audio.Media.DEFAULT_SORT_ORDER;
       mUri = Audio.Media.EXTERNAL_CONTENT_URI;
       mFragmentGroupId = 89;
       mType = TYPE_ALBUM;
       mTitleColumn = MediaColumns.TITLE; 
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:20,代码来源:AlbumListFragment.java

示例14: setupFragmentData

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
public void setupFragmentData(){
    mAdapter = new RecentlyAddedAdapter(getActivity(), R.layout.music_listview_items,
            null, new String[] {}, new int[] {}, 0);
	mProjection = new String[] {
            BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST
    };
    StringBuilder where = new StringBuilder();
    int X = MusicUtils.getIntPref(getActivity(), NUMWEEKS, 5) * 3600 * 24 * 7;
    where.append(MediaColumns.TITLE + " != ''");
    where.append(" AND " + AudioColumns.IS_MUSIC + "=1");
    where.append(" AND " + MediaColumns.DATE_ADDED + ">"
            + (System.currentTimeMillis() / 1000 - X));
    mWhere = where.toString();
    mSortOrder = MediaColumns.DATE_ADDED + " DESC";
    mUri = Audio.Media.EXTERNAL_CONTENT_URI;
    mTitleColumn = MediaColumns.TITLE;       
}
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:18,代码来源:RecentlyAddedFragment.java

示例15: onLoadFinished

import android.provider.MediaStore.Audio.AudioColumns; //导入依赖的package包/类
@Override
  public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
      if (data == null) {
          return;
      }
      long[] mNowPlaying = MusicUtils.getQueue();
  	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++){
  		data.moveToPosition(-1);
  		while (data.moveToNext()) {
              long audioid = data.getLong(data.getColumnIndexOrThrow(BaseColumns._ID));
          	if( audioid == mNowPlaying[i]) {
                  String trackName = data.getString(data.getColumnIndexOrThrow(MediaColumns.TITLE));
                  String artistName = data.getString(data.getColumnIndexOrThrow(AudioColumns.ARTIST));
                  String albumName = data.getString(data.getColumnIndexOrThrow(AudioColumns.ALBUM));
          		playlistCursor.addRow(new Object[] {audioid, trackName, artistName, albumName });
          	}
          }
  	}
      data.close();
mCursor = playlistCursor;
      super.onLoadFinished(loader, playlistCursor);
  }
 
开发者ID:hubcarl,项目名称:mobile-manager-tool,代码行数:25,代码来源:NowPlayingFragment.java


注:本文中的android.provider.MediaStore.Audio.AudioColumns类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。