Creating Playlist via code

2019-04-17 15:18发布

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条回答
Fickle 薄情
2楼-- · 2019-04-17 15:48

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.

查看更多
登录 后发表回答