问题
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:
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
来源:https://stackoverflow.com/questions/41233477/how-can-i-get-song-metadata-without-using-playuri-using-the-android-sdk