如何从Android的在建rintone列表发挥specifc音频文件? [英] How to play a specifc audio file from Android in build rintone list?

查看:134
本文介绍了如何从Android的在建rintone列表发挥specifc音频文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要知道的是它可以从Android的播放特定的音频文件,内置的铃声文件。例如,假设Tone_23采用的是Android的铃声列表,现在我需要打这个特殊的色调,当我点击一个按钮。我在谷歌搜索我有一个指导如何调用/显示RingtonePicker活动(整个铃声列表会显示出来)。如果可能的手段,请分享你的看法。先谢谢了。

I need to know is it possible to play a particular audio file from android in-built ringtone files. For example assume Tone_23 is in android ringtone list, now i need to play this particular tone, when i click a button. I searched in Google i got a guidance how to call/show RingtonePicker Activity (The entire Ringtone list will be displayed). If this possible means, kindly share your thoughts. Thanks in advance.

推荐答案

您可以尝试一些像这样的事情:

You can try some thing like this :

/**
 * Play ring tone.
 *
 * @param ringToneTitle the ring tone title
 */
void playRingTone(String ringToneTitle) {
    RingtoneManager ringtoneManager = new RingtoneManager(
            getApplicationContext());
    ringtoneManager.setType(RingtoneManager.TYPE_RINGTONE);

    int length = ringtoneManager.getCursor().getCount();

    for (int i = 0; i < length; i++) {
        Ringtone mRingtone = ringtoneManager.getRingtone(i);
        if (mRingtone != null) {
            Log.d("ringtoneTitle ", mRingtone.getTitle(getApplicationContext()));
            if(ringToneTitle.equalsIgnoreCase(mRingtone
                        .getTitle(getApplicationContext())) {
                mRingtone.play();
            }
        }
    }
}

希望这有助于。

补充:也看看这个类 RingtoneManager

RingtoneManager可以访问铃声,通知和其他类型的声音。它管理查询不同的媒体提供商和结果组合成一个单一的游标。它也提供了对每个铃声铃声。我们一般称这些声音铃声,然而TYPE_RINGTONE指的是适合于在电话振铃。

这篇关于如何从Android的在建rintone列表发挥specifc音频文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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