コード例 #1
0
 /** 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);
   }
 }
コード例 #2
0
 /** Shuffle all the tracks */
 public void shuffleAll() {
   Uri uri = Audio.Media.EXTERNAL_CONTENT_URI;
   String[] projection = new String[] {BaseColumns._ID};
   String selection = AudioColumns.IS_MUSIC + "=1";
   String sortOrder = Audio.Media.DEFAULT_SORT_ORDER;
   Cursor cursor = MusicUtils.query(this, uri, projection, selection, null, sortOrder);
   if (cursor != null) {
     MusicUtils.shuffleAll(this, cursor);
     cursor.close();
     cursor = null;
   }
 }