Contents
Bạn đang tìm kiếm từ khóa MediaStore audio playlists được Update vào lúc : 2022-03-08 16:06:16 . Với phương châm chia sẻ Thủ Thuật Hướng dẫn trong nội dung bài viết một cách Chi Tiết Mới Nhất. Nếu sau khi tìm hiểu thêm nội dung bài viết vẫn ko hiểu thì hoàn toàn có thể lại Comment ở cuối bài để Admin lý giải và hướng dẫn lại nha.
File:
LibManager.java
Project:
Blazers007/WavePlayer
/** 批量向歌单添加音乐 */
public static void addSongListToPlaylist(
final Context context, final PlayList playlist, final ArrayList songs)
Cursor cur =
context
.getContentResolver()
.query(
MediaStore.Audio.Playlists.Members.getContentUri(
“external”, playlist.getmPlayListId()),
null,
null,
null,
MediaStore.Audio.Playlists.Members.TRACK + ” ASC”);
long count = 0;
if (cur.moveToLast())
count = cur.getLong(cur.getColumnIndex(MediaStore.Audio.Playlists.Members.TRACK));
cur.close();
ContentValues[] values = new ContentValues[songs.size()];
for (int i = 0; i < songs.size(); i++)
values[i] = new ContentValues();
values[i].put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, count + 1);
values[i].put(MediaStore.Audio.Playlists.Members.AUDIO_ID, songs.get(i).getmSongId());
Uri uri =
MediaStore.Audio.Playlists.Members.getContentUri("external", playlist.getmPlayListId());
ContentResolver resolver = context.getContentResolver();
resolver.bulkInsert(uri, values);
resolver.notifyChange(Uri.parse("content://truyền thông"), null);
File:
LibManager.java
Project:
Blazers007/WavePlayer
/** 向歌单添加音乐 */
public static void addSongToPlaylist(
final Context context, final PlayList playlist, final Song tuy nhiên)
Cursor cur =
context
.getContentResolver()
.query(
MediaStore.Audio.Playlists.Members.getContentUri(
“external”, playlist.getmPlayListId()),
null,
null,
null,
MediaStore.Audio.Playlists.Members.TRACK + ” ASC”);
long count = 0;
if (cur.moveToLast())
count = cur.getLong(cur.getColumnIndex(MediaStore.Audio.Playlists.Members.TRACK));
cur.close();
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, count + 1);
values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, tuy nhiên.getmSongId());
Uri uri =
MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlist.getmPlayListId());
ContentResolver resolver = context.getContentResolver();
resolver.insert(uri, values);
resolver.notifyChange(Uri.parse(“content://truyền thông”), null);
File:
MusicUtils.java
Project:
Bartlomiej-Ozieblo/Play
public static List getAllSongsFromPlaylist(
ContentResolver contentResolver, long playlistId)
String[] projection =
MediaStore.Audio.Playlists.Members._ID,
MediaStore.Audio.Playlists.Members.DATA,
MediaStore.Audio.Playlists.Members.ARTIST,
MediaStore.Audio.Playlists.Members.TITLE,
MediaStore.Audio.Playlists.Members.ALBUM,
MediaStore.Audio.Playlists.Members.DURATION,
MediaStore.Audio.Playlists.Members.PLAY_ORDER
;
Cursor cursor =
contentResolver.query(
MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistId),
projection,
null,
null,
MediaStore.Audio.Playlists.Members.PLAY_ORDER);
if (cursor != null)
List songs = new ArrayList();
while (cursor.moveToNext())
songs.add(new Song(cursor));
return songs;
return null;
File:
MusicUtils.java
Project:
Bartlomiej-Ozieblo/Play
public static void addAlbumToPlaylist(ContentResolver contentResolver, long playlistId, long id)
String[] projection =
MediaStore.Audio.Media._ID,
;
String selection = MediaStore.Audio.Media.ALBUM_ID + “=” + id;
Cursor cursor =
contentResolver.query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
projection,
selection,
null,
MediaStore.Audio.Media.TRACK);
if (cursor != null)
int base = getLastTrackNumber(contentResolver, playlistId) + 1;
while (cursor.moveToNext())
ContentValues contentValues = new ContentValues();
contentValues.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, cursor.getLong(0));
contentValues.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, base);
base++;
contentResolver.insert(
MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistId),
contentValues);
File:
LibManager.java
Project:
Blazers007/WavePlayer
/** 获得播放清单里的所有歌曲 */
public static ArrayList getPlayListSongs(Context context, PlayList playList)
ArrayList songs = new ArrayList();
Cursor cursor =
context
.getContentResolver()
.query(
MediaStore.Audio.Playlists.Members.getContentUri(
“external”, playList.getmPlayListId()),
playListSongProjection,
MediaStore.Audio.Media.IS_MUSIC + ” != 0″,
null,
null);
for (int i = 0; i < cursor.getCount(); i++)
cursor.moveToPosition(i);
Song tuy nhiên =
new Song(
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.AUDIO_ID)),
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.TITLE)),
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ARTIST)),
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ALBUM)),
cursor.getLong(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.DURATION)),
cursor.getString(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.DATA)),
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ALBUM_ID)),
cursor.getInt(cursor.getColumnIndex(MediaStore.Audio.Playlists.Members.ARTIST_ID)));
songs.add(tuy nhiên);
cursor.close();
return songs;
/**
* Builds a query that will return all the songs in the playlist with the given id.
*
* @param id The id of the playlist in MediaStore.Audio.Playlists.
* @param projection The columns to query.
* @param selection The selection to pass to the query, or null.
* @return The initialized query.
*/
public static QueryTask buildPlaylistQuery(long id, String[] projection, String selection)
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, id);
String sort = MediaStore.Audio.Playlists.Members.PLAY_ORDER;
QueryTask result = new QueryTask(uri, projection, selection, null, sort);
result.type = TYPE_PLAYLIST;
return result;
/**
* Creates the @link Cursor used to run the query.
*
* @param context The @link Context to use.
* @param playlistID The playlist the songs belong to.
* @return The @link Cursor used to run the tuy nhiên query.
*/
public static final Cursor makePlaylistSongCursor(
final Context context, final String playlistID)
final StringBuilder mSelection = new StringBuilder();
mSelection.append(AudioColumns.IS_MUSIC + “=1″);
mSelection.append(” AND ” + AudioColumns.TITLE + ” != ””); // $NON-NLS-2$
return context
.getContentResolver()
.query(
MediaStore.Audio.Playlists.Members.getContentUri(“external”, Long.valueOf(playlistID)),
new String[]
/* 0 */
MediaStore.Audio.Playlists.Members._ID,
/* 1 */
MediaStore.Audio.Playlists.Members.AUDIO_ID,
/* 2 */
AudioColumns.TITLE,
/* 3 */
AudioColumns.ARTIST,
/* 4 */
AudioColumns.ALBUM
,
mSelection.toString(),
null,
MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
public static void addToPlaylist(Context context, long[] ids, long playlistid)
if (ids == null)
// this shouldn’t happen (the menuitems shouldn’t be visible
// unless the selected item represents something playable
Log.e(“MusicBase”, “ListSelection null”);
else
int size = ids.length;
ContentResolver resolver = context.getContentResolver();
// need to determine the number of items currently in the playlist,
// so the play_order field can be maintained.
String[] cols = new String[] “count(*)”;
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistid);
Cursor cur = resolver.query(uri, cols, null, null, null);
cur.moveToFirst();
int base = cur.getInt(0);
cur.close();
int numinserted = 0;
for (int i = 0; i < size; i += 1000)
makeInsertItems(ids, i, 1000, base);
numinserted += resolver.bulkInsert(uri, sContentValuesCache);
String message =
context
.getResources()
.getQuantityString(R.plurals.NNNtrackstoplaylist, numinserted, numinserted);
Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
// mLastPlaylistSelected = playlistid;
File:
PlaylistSongFragment.java
Project:
Helseth/Apollo
/** @inheritDoc */
@Override
public void remove(final int which)
mSong = mAdapter.getItem(which – 1);
mAdapter.remove(mSong);
mAdapter.notifyDataSetChanged();
final Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, mPlaylistId);
getActivity()
.getContentResolver()
.delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + “=” + mSong.mSongId, null);
public static void removeFromPlaylist(ContentResolver resolver, int audioId, long playlistId)
String[] cols = new String[] “count(*)”;
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistId);
Cursor cur = resolver.query(uri, cols, null, null, null);
cur.moveToFirst();
final int base = cur.getInt(0);
cur.close();
ContentValues values = new ContentValues();
resolver.delete(uri, MediaStore.Audio.Playlists.Members.AUDIO_ID + “=” + audioId, null);
// Adds the specified tuy nhiên to Android’s MediaStore.
public static void addToMediaStorePlaylist(
ContentResolver resolver, int audioId, long playlistId)
String[] cols = new String[] “count(*)”;
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistId);
Cursor cur = resolver.query(uri, cols, null, null, null);
cur.moveToFirst();
final int base = cur.getInt(0);
cur.close();
ContentValues values = new ContentValues();
values.put(MediaStore.Audio.Playlists.Members.PLAY_ORDER, Integer.valueOf(base + audioId));
values.put(MediaStore.Audio.Playlists.Members.AUDIO_ID, audioId);
resolver.insert(uri, values);
public static long[] getSongListForPlaylist(Context context, long plid)
final String[] ccols = new String[] MediaStore.Audio.Playlists.Members.AUDIO_ID;
Cursor cursor =
query(
context,
MediaStore.Audio.Playlists.Members.getContentUri(“external”, plid),
ccols,
null,
null,
MediaStore.Audio.Playlists.Members.DEFAULT_SORT_ORDER);
if (cursor != null)
long[] list = getSongListForCursor(cursor);
cursor.close();
return list;
return sEmptyList;
File:
MusicUtils.java
Project:
Bartlomiej-Ozieblo/Play
public static int getLastTrackNumber(ContentResolver contentResolver, long playlistId)
String[] projection =
MediaStore.Audio.Playlists.Members._ID, MediaStore.Audio.Playlists.Members.PLAY_ORDER
;
String selection = MediaStore.Audio.Playlists.Members.PLAYLIST_ID + “=” + playlistId;
Cursor cursor =
contentResolver.query(
MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistId),
projection,
selection,
null,
MediaStore.Audio.Playlists.Members.PLAY_ORDER);
if (cursor != null && cursor.moveToLast())
return cursor.getInt(1);
else
return -1;
File:
MusicUtils.java
Project:
Bartlomiej-Ozieblo/Play
public static void clearPlaylist(ContentResolver contentResolver, long playlistId)
contentResolver.delete(
MediaStore.Audio.Playlists.Members.getContentUri(“external”, playlistId), null, null);
// Playlist thành viên retriever
public ArrayList getSongsInPlaylist(PlaylistItem pl)
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, pl.id);
return queryForSongs(uri, null, MediaStore.Audio.Media.IS_MUSIC + “=1”, null, null);
public static void clearPlaylist(Context context, int plid)
Uri uri = MediaStore.Audio.Playlists.Members.getContentUri(“external”, plid);
context.getContentResolver().delete(uri, null, null);
return;
://.youtube/watch?v=DXbK_eQdrw8
Bạn vừa đọc nội dung bài viết Với Một số hướng dẫn một cách rõ ràng hơn về Review MediaStore audio playlists tiên tiến và phát triển nhất
Bạn đang tìm một số trong những Chia SẻLink Tải MediaStore audio playlists Free.
Nếu sau khi đọc nội dung bài viết MediaStore audio playlists vẫn chưa hiểu thì hoàn toàn có thể lại Comment ở cuối bài để Admin lý giải và hướng dẫn lại nha
#MediaStore #audio #playlists
Tra Cứu Mã Số Thuế MST KHƯƠNG VĂN THUẤN Của Ai, Công Ty Doanh Nghiệp…
Các bạn cho mình hỏi với tự nhiên trong ĐT mình gần đây có Sim…
Thủ Thuật về Nhận định về nét trẻ trung trong môi trường tự nhiên vạn…
Thủ Thuật về dooshku là gì - Nghĩa của từ dooshku -Thủ Thuật Mới 2022…
Kinh Nghiệm Hướng dẫn Tìm 4 số hạng liên tục của một cấp số cộng…
Mẹo Hướng dẫn Em hãy cho biết thêm thêm nếu đèn huỳnh quang không còn…