我試過在下面的鏈接中找到的更改,但無濟於事。需要關閉MediaRecorder在狀態更改時播放的聲音
How to shut off the sound MediaRecorder plays when the state changes
我都嘗試
AudioManager audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE);
audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, false);
audioManager.setStreamMute(AudioManager.STREAM_MUSIC,false);
和
// disable sound for recording.
// disable sound when recording.
((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_ALARM,true);
((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_DTMF,true);
((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_MUSIC,true);
((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_RING,true);
((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_SYSTEM,true);
((AudioManager)activity.getApplicationContext().getSystemService(Context.AUDIO_SERVICE)).setStreamMute(AudioManager.STREAM_VOICE_CALL,true);
但我仍然得到的聲音時,我開始媒體記錄器。我試圖把該代碼同時在應用程序的啓動和直接前:
mediaRecorder.start();
是否有任何其他建議?
因此,您在播放音樂以及在做記錄時應該停止播放什麼? –
不,我正在按順序錄制一系列視頻並將它們保存到文件中,以便我可以分段下載整個視頻。 MediaRecorder在每個視頻開始時播放快門聲音。我試圖關閉它,以免它在序列中一遍又一遍地響徹。 –