Java Code Examples for android.provider.MediaStore.Audio.AudioColumns#ALBUM
The following examples show how to use
android.provider.MediaStore.Audio.AudioColumns#ALBUM .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: QuickQueueFragment.java From mobile-manager-tool with MIT License | 6 votes |
@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); }
Example 2
Source File: QuickQueueFragment.java From mobile-manager-tool with MIT License | 6 votes |
/** * 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); }
Example 3
Source File: AlbumListFragment.java From mobile-manager-tool with MIT License | 6 votes |
@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; }
Example 4
Source File: RecentlyAddedFragment.java From mobile-manager-tool with MIT License | 6 votes |
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; }
Example 5
Source File: NowPlayingFragment.java From mobile-manager-tool with MIT License | 6 votes |
@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); }
Example 6
Source File: GenreListFragment.java From mobile-manager-tool with MIT License | 6 votes |
public void setupFragmentData(){ mAdapter = new GenreListAdapter(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 + " != ''"); mWhere = where.toString(); mSortOrder = Genres.Members.DEFAULT_SORT_ORDER; mUri = Genres.Members.getContentUri(EXTERNAL, getArguments().getLong(BaseColumns._ID)); mFragmentGroupId = 3; mType = TYPE_GENRE; mTitleColumn = MediaColumns.TITLE; }
Example 7
Source File: ArtistListFragment.java From mobile-manager-tool with MIT License | 6 votes |
@Override public void setupFragmentData(){ mAdapter = new ArtistListAdapter(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 artist_id = getArguments().getLong(BaseColumns._ID); where.append(" AND " + AudioColumns.ARTIST_ID + "=" + artist_id); mWhere = where.toString(); mSortOrder = MediaColumns.TITLE; mUri = Audio.Media.EXTERNAL_CONTENT_URI; mFragmentGroupId = 88; mType = TYPE_ARTIST; mTitleColumn = MediaColumns.TITLE; }
Example 8
Source File: AddIdCursorLoader.java From mobile-manager-tool with MIT License | 5 votes |
@Override public Cursor loadInBackground() { Cursor mediaCursor = getContext().getContentResolver().query(mUri, mProjection, mSelection, mSelectionArgs, mSortOrder); //Get cursor filled with Audio Id's String [] projection = new String[] { BaseColumns._ID, AlbumColumns.ALBUM }; Uri uri = Audio.Albums.EXTERNAL_CONTENT_URI; String sortOrder = Audio.Albums.DEFAULT_SORT_ORDER; Cursor albumCursor = getContext().getContentResolver().query(uri, projection, null, null, sortOrder); //Matrix cursor to hold final data to be returned to calling context MatrixCursor cursor = new MatrixCursor( new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ARTIST, AudioColumns.ALBUM, AudioColumns.ALBUM_ID}); //Map data from Audio Id cursor to the ALbumName Colum ContentQueryMap mQueryMap = new ContentQueryMap(albumCursor, AlbumColumns.ALBUM, false, null); Map<String, ContentValues> data = mQueryMap.getRows(); if (mediaCursor != null) { while(mediaCursor.moveToNext()) { String id = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(BaseColumns._ID)); String title = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(MediaColumns.TITLE)); String artist = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(AudioColumns.ARTIST)); String album = mediaCursor.getString(mediaCursor.getColumnIndexOrThrow(AudioColumns.ALBUM)); ContentValues tData = data.get(album); String albumid = (String) tData.get(BaseColumns._ID); cursor.addRow(new String[] {id, title, artist, album, albumid}); } mediaCursor.close(); } if (cursor != null) { // Ensure the cursor window is filled registerContentObserver(cursor, mObserver); } return cursor; }
Example 9
Source File: NowPlayingFragment.java From mobile-manager-tool with MIT License | 5 votes |
@Override public void setupFragmentData() { mAdapter = new NowPlayingAdapter(getActivity(), R.layout.music_dragsort_listview_items, null, new String[] {}, new int[] {}, 0); mProjection = new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST }; mSortOrder = Audio.Media.DEFAULT_SORT_ORDER; mUri = Audio.Media.EXTERNAL_CONTENT_URI; StringBuilder where = new StringBuilder(); long[] mNowPlaying = MusicUtils.getQueue(); if (mNowPlaying.length <= 0){ where.append(AudioColumns.IS_MUSIC + "=1").append(" AND " + MediaColumns.TITLE + " != ''"); } else{ where.append(BaseColumns._ID + " IN ("); for (long queue_id : mNowPlaying) { where.append(queue_id + ","); } where.deleteCharAt(where.length() - 1); where.append(")"); } mWhere = where.toString(); mMediaIdColumn = BaseColumns._ID; mType = TYPE_SONG; mFragmentGroupId = 91; }
Example 10
Source File: PlaylistListFragment.java From mobile-manager-tool with MIT License | 5 votes |
@Override public void setupFragmentData() { mAdapter = new PlaylistListAdapter(getActivity(), R.layout.music_dragsort_listview_items, null, new String[] {}, new int[] {}, 0, mPlaylistId); StringBuilder where = new StringBuilder(); where.append(AudioColumns.IS_MUSIC + "=1").append(" AND " + MediaColumns.TITLE + " != ''"); mWhere = where.toString(); mSortOrder = Playlists.Members.PLAY_ORDER; if(mPlaylistId == PLAYLIST_FAVORITES){ long favorites_id = MusicUtils.getFavoritesId(getActivity()); mProjection = new String[] { Playlists.Members._ID, Playlists.Members.AUDIO_ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST }; mUri = Playlists.Members.getContentUri(EXTERNAL, favorites_id); } else{ mProjection = new String[] { Playlists.Members._ID, Playlists.Members.AUDIO_ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST }; mUri = Playlists.Members.getContentUri(EXTERNAL, mPlaylistId); } mMediaIdColumn = Playlists.Members.AUDIO_ID; mType = TYPE_PLAYLIST; mFragmentGroupId = 90; }
Example 11
Source File: MusicSongListFragment.java From mobile-manager-tool with MIT License | 4 votes |
public void setupFragmentData(){ mAdapter = new ApolloSongListAdapter(getActivity(), R.layout.music_listview_items, null, new String[] {}, new int[] {}, 0); mProjection = new String[] { BaseColumns._ID, MediaColumns.TITLE, AudioColumns.ALBUM, AudioColumns.ARTIST, AudioColumns.DATA }; StringBuilder where = new StringBuilder(); where.append(AudioColumns.IS_MUSIC).append(" =1 AND ").append( MediaColumns.TITLE).append(" != ''"); mWhere = where.toString(); mSortOrder = Audio.Media.DEFAULT_SORT_ORDER; mUri = Audio.Media.EXTERNAL_CONTENT_URI; mFragmentGroupId = 3; mType = TYPE_SONG; mTitleColumn = MediaColumns.TITLE; // 随机播放 // View shuffle_temp = View.inflate(getActivity(), R.layout.shuffle_all, null); // mListView.addHeaderView(shuffle_temp); // RelativeLayout shuffle = (RelativeLayout)shuffle_temp.findViewById(R.id.shuffle_wrapper); // shuffle.setVisibility(View.VISIBLE); // shuffle.setOnClickListener(new RelativeLayout.OnClickListener() { // public void onClick(View v) // { // Uri uri = Audio.Media.EXTERNAL_CONTENT_URI; // String[] projection = new String[] { // BaseColumns._ID // }; // String selection = AudioColumns.IS_MUSIC + "=1"; // String sortOrder = "RANDOM()"; // Cursor cursor = MusicUtils.query(getActivity(), uri, projection, selection, null, sortOrder); // if (cursor != null) { // MusicUtils.shuffleAll(getActivity(), cursor); // cursor.close(); // cursor = null; // } // } // }); }
Example 12
Source File: NowPlayingFragment.java From mobile-manager-tool with MIT License | 4 votes |
/** * 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); }