简体   繁体   English

在 Android 工作室中使用 MediaStore 限制播放列表中的歌曲数量

[英]Using MediaStore in Android studio to limit the number of songs in a playlist

I'm an absolute beginner in Java and Android Studio and I am trying to edit an open source music player using Android Studio.我是 Java 和 Android Studio 的绝对初学者,我正在尝试使用 Android Studio 编辑开源音乐播放器。 The app is currently creating a "last added" playlist and sorting the songs by date using MediaStore.Audio.Media.DATE_ADDED Is there a way to limit the number of songs in this playlist?该应用程序当前正在创建“最后添加”播放列表,并使用 MediaStore.Audio.Media.DATE_ADDED 按日期对歌曲进行排序。有没有办法限制此播放列表中的歌曲数量?

I hope this description is precise enough..我希望这个描述足够准确..

Thank you:)谢谢:)

You have to set Limit in sortOrder parameter of contentResolver query.您必须在contentResolver查询的 sortOrder 参数中设置Limit

 String sortOrder = MediaStore.Audio.Media.DATE_ADDED + " DESC LIMIT 1";
 Cursor cur = getContentResolver().query(uri, null, null, null, sortOrder);

GGK GGK

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MediaStore:从播放列表中删除所有 ident 歌曲 - MediaStore: Deletes all ident Songs from Playlist Android MediaStore播放列表返回错误的曲目 - Android MediaStore Playlist returning wrong tracks 如何使用文件浏览器Android Studio将歌曲添加到我的歌曲播放列表中? - How can I add a song to my playlist of songs with file explorer Android Studio? 在 mediastore 中获取歌曲的封面 - Get cover of the songs in mediastore 从MediaStore检索最近的歌曲 - Retrieving recent songs from the MediaStore 如何在 android 工作室中使用 MediaStore Api 在 android 11 中获取特定文件夹,如 WhatsApp (.Status) 文件夹 - How to get specific folder like WhatsApp (.Status) folder in android 11 using MediaStore Api in android studio Android Studio如何在歌曲中循环播放MediaPlayer - Android Studio how to loop through songs MediaPlayer 如何从网站或Android IP播放器项目的静态IP读取歌曲播放列表 - How to read songs playlist from website or static IP for my Android media player project 在 Android Q (API29) 及更高版本中将歌曲添加到播放列表会引发 SecurityException - Adding songs to a playlist in Android Q (API29) and above throws a SecurityException 如何使用MediaStore保存Android Q中的图片? - How to save an image in Android Q using MediaStore?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM