【问题标题】:how to mute the "beep" by MediaRecorder.start()?如何通过 MediaRecorder.start() 使“哔”静音?
【发布时间】:2014-12-16 05:27:06
【问题描述】:

我已经尝试了以下链接中提到的所有方法

How to shut off the sound MediaRecorder plays when the state changes

Need to shut off the sound MediaRecorder plays when the state changes

但它们都不起作用。

有人知道如何实现吗?

【问题讨论】:

  • 我也在找同样的。

标签: android mediarecorder android-audiomanager


【解决方案1】:

虽然我来不及回答。它仍然可以帮助那些在谷歌上搜索相同问题的人。

在启动媒体记录器之前添加以下两行代码.. 它会让手机静音..

//mute phone
 AudioManager audioManager = (AudioManager) context.getSystemService(AUDIO_SERVICE);
 audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
 mediaRecorder.start();

启动媒体记录器后等待一两秒并取消手机静音,您可以使用以下可运行...

new Thread(new UnmuterThread()).start();


 //timer thread to un-mute phone after 1 sec
//This is runnable inner class inside your activity/service
class UnmuterThread implements Runnable{

    @Override
    public void run() {
        synchronized (this){
            try {
                wait(1000);
            } catch (InterruptedException e) {
            } finally {
                //unmute the phone
                AudioManager audioManager1 = (AudioManager) context.getSystemService(AUDIO_SERVICE);
                audioManager1.setRingerMode(AudioManager.RINGER_MODE_NORMAL);                                   }
        }
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多