From 01616e577b6e75583e1f23b73b8a17e564f62f74 Mon Sep 17 00:00:00 2001 From: William Breathitt Gray Date: Sun, 13 Mar 2016 12:54:44 -0400 Subject: [PATCH] Silence ringer during recording transition MediaRecorder produces a "chime" sound on state changes (e.g. on the stop and start of recordings). Some versions of Android use STREAM_SYSTEM to produce the sound, but others such as version 4.2.1 on the Galaxy Nexus use STREAM_RING. This patch silences the ringer during recording transitions in order to prevent the "chime" sound from being heard on each RestartRecording method call on relevant Android versions. --- src/es/esy/CosyDVR/BackgroundVideoRecorder.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/es/esy/CosyDVR/BackgroundVideoRecorder.java b/src/es/esy/CosyDVR/BackgroundVideoRecorder.java index fdc5d6e..ed3eb47 100644 --- a/src/es/esy/CosyDVR/BackgroundVideoRecorder.java +++ b/src/es/esy/CosyDVR/BackgroundVideoRecorder.java @@ -455,8 +455,11 @@ public void RestartRecording() { AudioManager manager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); manager.setStreamSolo(AudioManager.STREAM_SYSTEM, true); manager.setStreamMute(AudioManager.STREAM_SYSTEM, true); + int savedRingerMode = manager.getRingerMode(); + manager.setRingerMode(AudioManager.RINGER_MODE_SILENT); StopRecording(); StartRecording(); + manager.setRingerMode(savedRingerModer); manager.setStreamMute(AudioManager.STREAM_SYSTEM, false); manager.setStreamSolo(AudioManager.STREAM_SYSTEM, false); }