获取MP3持续时间机器人 [英] Get mp3 duration in android

查看:105
本文介绍了获取MP3持续时间机器人的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得MP3曲目持续时间不创建MediaPlayer的实例?我只是需要显示的MP3歌曲长度的MP3文件列表,所以我觉得我不应该在列表中创建的每个曲目MediaPlayer对象

How to get mp3 track duration without creating MediaPlayer instance? I just need to show mp3 song length in mp3 file list, so I think that I shouldn't create MediaPlayer object for each of tracks in the list

和另一位说:

有时MediaPlayer的返回歌曲的错误的时间(我认为它是因为码率这些文件是DINAMIC)。我怎样才能得到这首歌的正确时间?

sometimes MediaPlayer returns wrong duration of the song ( I think its so because bitrate of those files is dinamic ). How can I get right duration of the song?

推荐答案

您可以使用的类MediaMetadataRetriever 以得到一首歌曲的持续时间。使用<一个href="http://developer.android.com/reference/android/media/MediaMetadataRetriever.html#METADATA_KEY_DURATION"相对=nofollow>与<组合METADATA_KEY_DURATION href="http://developer.android.com/reference/android/media/MediaMetadataRetriever.html#extractMetadata%28int%29"相对=nofollow> extractMetadata()功能可按

You can use the MediaMetadataRetriever to get the duration of a song. Use the METADATA_KEY_DURATION in combination with the extractMetadata() funciton.

这篇关于获取MP3持续时间机器人的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆