如何检索MP3文件的持续时间(秒)在Android SDK中小于10 [英] How to retrieve MP3 file duration(secs) in android sdk <10

查看:139
本文介绍了如何检索MP3文件的持续时间(秒)在Android SDK中小于10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已存储的MP3文件设定在我的SD卡。现在我想检索秒的持续时间。我通过几个环节去了,我使用 MediaMetadataRetriever 类是能够找到解决办法只能从SDK版本10。但我的要求是SDK版本7.有什么办法,找出MP3文件的时间。我很抱歉,如果这是一个重复的问题在这里。

I have stored set of MP3 files in my sd card. Now I want to retrieve its duration in seconds. I went through few links and I was able to find solution only from SDK version 10 using the MediaMetadataRetriever class. But my requirement is for SDk version 7. Is there any way to find out the duration of mp3 files. I am sorry if this is a repeated question here.

我知道,使用MediaPlayer的 getDuration()解决了这个问题。但我不希望使用此。

I know that using MediaPlayer's getDuration() solves this issue. But I don't want to use this.

任何帮助很多AP preciated。

Any help is much appreciated.

推荐答案

你有足够的数据来查询EXTERNAL_CONTENT_URI?随着标题,比如,你可以做到以下几点:

Do you have enough data to query the EXTERNAL_CONTENT_URI? With the title, for instance, you could do the following:

Cursor cursor= getContentResolver().query(android.provider.MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,null,android.provider.MediaStore.Audio.Media.TITLE+"=='Hallelujah'",null,null);
cursor.moveToFirst();
int duration=cursor.getInt(cursor.getColumnIndex(android.provider.MediaStore.Audio.Media.DURATION));

这篇关于如何检索MP3文件的持续时间(秒)在Android SDK中小于10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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