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

烂漫一生 提交于 2019-12-12 04:30:10

问题


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

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