android-audiomanager

Stop audio playing when another app's audio comes in

≡放荡痞女 提交于 2019-12-06 10:28:44
I would like to know how do I implement the behaviour, so that my radio streaming would stop playing if other audio would come in to play - for instance, user starts playing music, makes a call etc. In other words, how does my ExoPlayers knows that other audio is being played, or if it doesn't, do I have to listen for mediaplayer and call events? Here is an example i made for an audio state manager , you can use it as a template. (created in 2016) As per the question - You need to use an OnAudioFocusChangeListener , Read the comments in the example: public class AudioStateManager { private

Unable to retrieve AudioTrack pointer for write()

ぐ巨炮叔叔 提交于 2019-12-06 03:37:53
问题 I am trying to implement AudioTrack to retrieve audio in my android device for incoming call from IAX but facing exception after some while . private void writeBuff(short[] buf) { try { if (this.track == null) { Log.w("IAX2Audio", "write() without an AudioTrack"); return; } int written = 0; while (written < buf.length) { if (this.track != null) { int res; res = this.track.write(buf, written, buf.length - written); switch (res) { case AudioTrack.ERROR_INVALID_OPERATION: Log.e("IAX2Audio",

Audiomanager Speaker not working

这一生的挚爱 提交于 2019-12-06 03:17:57
I'm trying to enable the speaker while I am in a call: final AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE); audioManager.setSpeakerphoneOn(true); I tried to check after the setSpeakerphoneOn() the audiomanager and get that the speaker is still not on by asking isSpeakerphoneOn() audioManager.isSpeakerphoneOn(); In my log I can see some errors that I can't understand: E/AudioManager: Don't setBluetoothScoOn-PackageName: com.myapp.app on = false E/AudioManager: Don't setSpeakerphoneOn-PackageName: com.myapp.app on = true I can't find anything about

Android audiomanager - I want to set silent mode, but applied the priority mode (lollipop)

£可爱£侵袭症+ 提交于 2019-12-05 10:00:36
问题 My problem is occurs in android lollipop os. I want to set 'silent mode', but lollipop os applies to ' priority mode '. (I use AudioManager) Is there any way I can apply the 'silent mode' instead of 'priority mode'? My code : AudioManager mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE); mAudioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT); 回答1: Due to changes in API try using the int value 0 instead of AudioManager.RINGER_MODE_SILENT AudioManager mAudioManager =

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

对着背影说爱祢 提交于 2019-12-05 03:38:06
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 ? 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

Android 5.0+ AudioManager setMode not working

我的梦境 提交于 2019-12-05 02:32:53
问题 i am working on AudioManager which is a Android SystemService. with Android System 5.0+ , i encounter a problem which AudioManager the setMode method is not working . i through a test , Android M, Lollipop.. 5.0+ version , AudioManager setMode is not working . example : public void initAudioImageIcon(boolean initLoad) { boolean isAudioHeaderMode = IMSharedPreferences.getBooleanExtra(this, IMSPConstant.SP_NAME_MESSAGE, IMSPConstant.SP_KEY_AUDIO_HEADER_MODE); if (isAudioHeaderMode) {

Increase volume of recording Android AudioRecord

回眸只為那壹抹淺笑 提交于 2019-12-05 01:24:15
I'm using AudioRecord and lame to record mic input to a mp3 sample for 12 seconds. The audio is recorder as expected but I realized the volume is too low. Is there a way to increase the volume of the recording? Shrish There is no gain settings in the audioRecord class to play with, so you cannot control the volume of the audio being recorded. The low volume of the audio is related to the hardware and varies from device to device. Here are a few options you can try. 1) try opening in the audio record in different modes and see whats works best . check - http://developer.android.com/reference

Android: Hide Volume change bar from device?

笑着哭i 提交于 2019-12-04 23:40:15
问题 is there a way to hide the volume change bar/notification (however you might call it..btw. how do you call it?) ? i attached a screenshot above. this bar is shown everytime i change the volume (at least on my nexus test device). or is this a nexus special? 回答1: It is the default post-honeycomb volume slider which appears when you press volume up/down buttons. You cannot hide it in every screen of the system, but you can hide it in your activities. Add this to an activity where you want to

Changing data source for audio playback using existing MediaPlayer?

北城余情 提交于 2019-12-04 20:45:28
问题 I'm trying to use the same media player but change the data source. Here is what I'm trying to do: private MediaPlayer mMediaPlayer; public void pickFile1() { initMediaPlayer("myfile1.mp3"); } public void pickFile2() { initMediaPlayer("myfile2.mp3"); } private void initMediaPlayer(String mediafile) { // Setup media player, but don't start until user clicks button! try { if (mMediaPlayer == null) { mMediaPlayer = new MediaPlayer(); } else { mMediaPlayer.reset(); // so can change data source

How to route default audio to ear piece when headphones are connected?

五迷三道 提交于 2019-12-04 19:51:47
I am developing an app in which we need to use the headphone jack as a button only. Requirement : Play the default audio (calling) via earpiece when headsets are connected (no need of audio through headphones) There are many example of routing audio through speaker and headphones and also bluetooth headsets but nothing about routing the audio through ear speakers of devices if headsets are connected. I have tried a lot and some links are Android : Force audio routing (not working in my scenario) I have checked SoundAbout( https://play.google.com/store/apps/details?id=com.woodslink.android