android-audiomanager

how to resgister my MusicPlayer App to OnAudioFocusChangeListener

大城市里の小女人 提交于 2019-12-11 04:55:23
问题 I am creating a music player app. I want: When the user plays a song using my app, then the default music player should get stopped(is playing) And if some other application starts playing when my app is already playing then mine should get stopped. I am able to work out with the 1st point using Audio Focus. But for the 2nd point, i.e. Handling AUDIOFOCUS_LOSS , i'm facing some issues. Problem: I've followed the documentation but how should I register my music player service to detect that

setRingerMode to normall during incoming call doesn't work on Samsung devices

左心房为你撑大大i 提交于 2019-12-11 03:55:50
问题 I've read here. Didn't find the answer. public class CallReceiver extends BroadcastReceiver { private TelephonyManager mTelephony; private IncomingPhoneStateListener mIncomingPhoneListener; private String number; private Context mContext; @Override public void onReceive(Context context, Intent intent) { try { mContext = context; number = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER); mTelephony = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

Intel INDE - How to control (mute) microphone input volume (input gain) in Android

一笑奈何 提交于 2019-12-11 03:32:35
问题 I'm using Intel INDE for video streaming purposes (Android) and it's giving me headaches to solve some problems. The main problem is how to mute/unmute the devices microphone in Android. Looks like Intel INDE is overriding the input volume to be always active. The only way I found is to not set the AudioFormatAndroid of Intel INDE API deleting these lines: audioFormat = new AudioFormatAndroid("audio/mp4a-latm", 44100, 1); capture.setTargetAudioFormat(audioFormat); The problem is that I need

android play sound with AudioTrack

倖福魔咒の 提交于 2019-12-10 18:06:22
问题 hello I have this code AudioTrack audioTrack; public void playAccordeon() { int minBufferSize = AudioTrack.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); int bufferSize = 512; if (audioTrack == null) { audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC, 44100, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, minBufferSize, AudioTrack.MODE_STREAM); audioTrack.play(); } int i = 0; byte[] s = new byte[bufferSize]; try {

How to disable the wired headset programmatically in Java

穿精又带淫゛_ 提交于 2019-12-10 17:35:02
问题 Please refer my question here. This question is an extension to that: How to check and redirect audio between wired headset and speaker phone? I was able to partially solve my problem by including the permissions <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" /> in my Android Manifest for that same piece of code. Now, I am able to enable and disable the phone speakers, but I am not able to turn off my wired headset connection programmatically, when the wired headset

how to mute the “beep” by MediaRecorder.start()?

那年仲夏 提交于 2019-12-10 03:36:35
问题 I have tried all methods mentioned in the following links How to shut off the sound MediaRecorder plays when the state changes Need to shut off the sound MediaRecorder plays when the state changes but none of them work. Anyone knows how to achieve that ? 回答1: 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 =

How to create oscilloscope for audio on android

百般思念 提交于 2019-12-09 20:08:34
问题 i am creating an app for audio recording with oscilloscope. i did the audio recording with the following code now i add oscilloscopse as shown in the figure.my requirement is oscilloscope's wave should be zigzac according to the user's voice tone. i have tried long time but i could not find solution. i do not have any idea to implement the oscilloscope. please help me how to do it and please provide some sample code snippets. thanks. audio recording code: recorder = new AudioRecord

Play audio file during a call, however the person on the other end is not able to hear it

半腔热情 提交于 2019-12-09 07:57:06
问题 I want to play audio file during a call and i'm able to play it but when i make a call it play file only on that device on which i have installed the application. here is my sample code by which i have played the audio file. public void play() { bufferSize = AudioTrack.getMinBufferSize(16000, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioTrack at = null; at = new AudioTrack(AudioManager.STREAM_VOICE_CALL, 16000, AudioFormat.CHANNEL_CONFIGURATION_MONO,

What is audio focus in Android class AudioManager?

拥有回忆 提交于 2019-12-09 02:51:19
问题 The AudioManager class has a method abandonAudioFocus() and another method requestAudioFocus() . I wonder what is audio focus? And what happens if an AudioManager object gets the audio focus or lost the audio focus? Thank you! 回答1: It has to do with priority when using the speakers, to prevent playing many things at once or being overridden. If you requestAudioFocus() , you're declaring that you want control. You can then listen with onAudioFocusChange(int focusChange) to see if anything else

AudioManager sending message to a Handler on a dead thread?

风流意气都作罢 提交于 2019-12-08 19:41:41
问题 I am trying to programmatically raise the volume to the STREAM_MUSIC stream's maximum value, but I am having a "Sending message to a Handler on a dead thread" issue when I do. Also, it seems like it does not raise the volume 100% of the time, although when I get this error, it will raise it MOST of the time. The code is: System.out.println("Maximum volume for this stream is: "+maxstreamvol+" and it used to be set to: "+currentvol); final AudioManager am = (AudioManager)this.getSystemService