有没有一种方法来确定一个音频文件的持续时间方法来、音频文件、持续时间

2023-09-03 21:17:13 作者:湿透

在Android的,什么是确定的音频文件的持续时间最简单的方法(假设我在手机上的文件的URI)?

In android, what is the simplest way to determine the duration of an audio file (assume I have an URI of the file on the phone)?

我是否需要创建和prepare的媒体播放器,我想确定文件的持续时间每个文件?

Do I need to create and prepare an media player for each file I want to determine the duration of the file?

感谢你。

推荐答案

如果MediaScanner是在手机上运行,​​那么你可以使用MediaStore来获得这些信息。

If MediaScanner is running on the phone then you can use MediaStore to get that information.

MediaStore