How can I get song metadata without using playUri using the Android SDK?

202 views Asked by At

I want to get song metadata from a URI without starting to play/buffer that song.

The only way I can see of doing it right now is calling playUri() and then getMetadata() but I don't want to play it immediately.

Is there any other way?

Thanks!

Edit: Is there a way to do this via the SDK with non-local files?

1

There are 1 answers

0
Maksim Ostrovidov On

Use MediaMetaDataRetreiver:

MediaMetadataRetriever retriever = new MediaMetadataRetriever();
retriever.setDataSource(context, uri);
String artist 
    = retreiver.extractMetadata(MediaMetadataRetriever.METADATA_KEY_ARTIST);
//etc
retriever.release(); //don't forget to call this when done