In above code we are setting data source and then preparing mediaplayer then calling start to play media file. It can be paused by pause API and stopped by calling stop.

Now that I am able to play audio file, I tried to fetch its metadata file to show detais of Audio file to user. Fetching metadata was not as easy as playing file as its requied to use ContentResolver API and at first glance it looks quite strange to use it. After spending some time I managed to fetch metadata using following code.

To fetch metadata first we need to decide which attributes we are instrested in. Following are quite frequently used attributes.

Then we need to use ContentResolver to query audio content provider to fetch metadata. I am instrested in query metadata for perticular file. So I am using MediaStore.MediaColumns.DISPLAY_NAME (filename) as selection and then specifying instrested filename in values array.

Hello. I have a question - how to make that query:All artists in selected folder like /sdcard/Music/How to get all songs I know. But how to get all artists from that folder and then songs by selected artist from custom folder ?