Creating Playlist via code

橙三吉。 提交于 2019-12-10 00:05:24

问题


For my latest project i want the user to be able to make playlist and save them to the phone. I want to make so when they make them in the application they will also show up when they look in the built in music app. Whats the best way of doing this? I know i will probably have to use MediaStore but other than that I'm a tad lost. Any information would help, just need a nudge in the right direction - Thanks


回答1:


You can use the content URI found in Media.AudioStore.Playlist class to access the playlist content provider. By inserting elements into the Playlist content provider you'll be able to the inserted playlists in the Music application.

Example code:

 ContentResolver contentResolver = Context.getContentResolver();
 //Get all the playlists
 Cursor playlist = contentResolver.query(
   Media.AudioStore.Playlist.getContentUri(Media.AudioStore.Playlist.EXTERNAL_CONTENT_URI));

You can play around with the classes more to get a better idea of how to use them. Note the inner class that Media.AudioStore.Playlist has, Media.AudioStore.Playlist.Memebers.



来源:https://stackoverflow.com/questions/7897668/creating-playlist-via-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!