如何使“哔哔"声静音通过MediaRecorder.start()? [英] how to mute the "beep" by MediaRecorder.start()?

查看:179
本文介绍了如何使“哔哔"声静音通过MediaRecorder.start()?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have tried all methods mentioned in the following links

如何关闭状态更改时会播放声音MediaRecorder

需要关闭状态更改时会播放声音MediaRecorder

但它们都不起作用.

任何人都知道如何实现这一目标吗?

Anyone knows how to achieve that ?

推荐答案

尽管我来不及回答.它仍然可以帮助所有正在搜寻同一问题的人们.

Though I am too late to answer it. It may still help peoples who all are googling the same problem.

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

Before starting media recorder add following two lines of code .. Its gonna mute phones sound..

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

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

After starting media recorder wait one or two seconds and un-mute the phone, u may use following runnable...

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);                                   }
        }
    }
}

这篇关于如何使“哔哔"声静音通过MediaRecorder.start()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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