Send recorded sound as microphone input

What should I write to send a recorded audio file as a microphone input in Android software?

Example:

The user writes "hello world."

He can then play the recording in the call.

+8
android audio audio-streaming
source share
2 answers

after you have the recorded file, you can open it as an InputStream or in any other way. BUT, if you are specifically looking for something like inputting sound into a call , then this is not possible. he defended the OS level.

if you are not dealing with regular ROMs and modified kernels. which is not official

+7
source share

It may send you in the right direction.

AudioManager.OnAudioFocusChangeListener, using this, you can get the status of the audio master in the code "focusChange = AUDIOFOCUS_LOSS_TRANSIENT" below (this state causes when the music is playing in the background, any incoming call has come) this state is completely in the hands of the developers, playing or pausing music . As in accordance with your requirements, since for the question you asked if you want to play music when the call is in the OFFHOOK STATE state, do not stop the music playing in the OFFHOOK state. And this is only possible when the headset is turned off.

AudioManager am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE); OnAudioFocusChangeListener afChangeListener = new OnAudioFocusChangeListener() { public void onAudioFocusChange(int focusChange) { if (focusChange == AUDIOFOCUS_LOSS_TRANSIENT // Pause playback (during incoming call) } else if (focusChange == AudioManager.AUDIOFOCUS_GAIN) { // Resume playback (incoming call ends) } else if (focusChange == AudioManager.AUDIOFOCUS_LOSS) { am.unregisterMediaButtonEventReceiver(RemoteControlReceiver); am.abandonAudioFocus(afChangeListener); // Stop playback (when any other app playing music in that situation current app stop the audio) } } }; 

The concept of using an audio driver (this is for windows, but it may work for android)

Just as there are printer drivers that do not connect to the printer at all, but rather write to a PDF file, virtual audio drivers that do not connect to a physical microphone at all, but can connect to other sources such as files or other programs, are also available.

I hope I don't break any rules by recommending free software, but the VB-Audio virtual cable should allow you to create a pair of virtual audio input and output devices. Then you can play MP3 in the virtual output device, and then set the virtual input device as your β€œmicrophone”. In theory, I think this should work.

If all else fails, you can always run your own virtual virtual audio driver. Microsoft provides some sample code, but unfortunately it does not apply to the older Windows XP audio system. There is probably a sample code for XP.

0
source share

All Articles