Android Speech Recognition while music is playing - android

referencing to Hoans answer here Jelly Bean Beep In Speech Recognition I tried to implement a speech recognizer in the background.
And it works all fine. The service runs in background and listens to words the user say.
My problem is:
If a music player is running and the speech recognizer restarts, the system sound stream is muted to prevent the beep sound of speech recognition. But muting this stream paues and mutes the music player, too.
Does anyone have an idea how to prevent the beep sound without muting the whole system?
I already tried to mute another stream but the system stream is the only one muting the beep.
I test on a Nexus 4 with Android 4.4
Best regards.

Related

Android MediaRecorder record voice only, not output

Writing an android application which will allow users to play music and record to that music. I've been using media player to play the background track and MediaRecorder to record in a background thread. When recording I get my voice from the mic and the output from the headphones. Is there a way to stop the output stream from being recorded as well? I'm using a 2012 Galaxy Nexus phone to test this.
I was using headphones with try connector which I think was the culprit. I tried with a regular trs connector and I only received the microphone feed.

How to mute downlink voice call on android?

I work with AOSP 4.4.2 build. We'd like to mute downlink voice call sound for a while. How can we that? We already test with AudioManager's setStreamMute, setStreamVolume, but it was not working on our projects.
Like a mute a camera shutter sounds, we now finding some solution on audio_policy.

Android - How to disable sound on video recording start?

On Android when you start recording video in your app there is a notification sound. Is there a reliable way to disable it?
For non-rooted devices, if the firmware allows muting that sound, you can mute it by using AudioManager.setStreamMute() on STREAM_MUSIC (or STREAM_SYSTEM on some devices) before recording and unmute when recording starts. It won't work if the firmware doesn't allow this. In this case, there is no way to disable it other than rooting it.

Play a sound only using phone audio

I'm developing a sort of alarm clock application and I need to play my sound specifically through the phone audio and not through Bluetooth. (I learned this the hard way as I missed all three of my set alarms this morning because the alarms played through my Bluetooth headset)
How can I play a sound that only plays through phone audio and not Bluetooth?
I had similar requirement when user select an option, i need to play audio from speaker. so i changed audio stream type to ring like mp.setAudioStreamType(AudioManager.STREAM_RING) and it worked. Hope this works for you too. (NOTE: some phones have limitation that audio is played from both speaker and bluetooth)

Android: when implementing a music player in my app, can i make sure there is no other media playing playing music right now?

I want my app to play music while it is running, but I don't want the music to overlap with the music currently being played from a different application (android music app or other external music app such as pandora, grooveshark or winamp).
My question is: is there a way to make sure that nothing else is playing right now regardless of the source?
Thanks!
As of android 2.2 you can use AudioManager.requestAudioFocus(), other audio players should listen for this focus change request and can stop/pause/lower volume of their audio according to what type of audio your focus requests. However not all audio playing apps have bothered to implement this yet.
To be nice you should also listen for audio focus change requests from other apps and pause your apps audio accordingly.
On earlier versions of android calling mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC); will usually stop any other music from playing

Categories

Resources