I am working on an android music player and I wanna have hand-free voice commands,i.e., don't need to press any button to start recording. the app should keep listening all the time. Is there a way ?
You could use the Houndify SDK for voice recognition. It can be triggered without a button press, and it has music domains for searching and controlling music playback.
http://www.soundhound.com/houndify
Related
I use the speech recognition and text-to-speech but I would like to mute the "beep" sound of the speech recognition and then unmute for hear the vocal synthesis.
I succeed to mute but when I want to set the volume at its maximum, it applies to the phone and not to my app.
How to manage this ?
Thanks
There is an answer you can refer to here regarding how to loop the recognition and silence the beep.
Whenever you call setStreamMute() it is for the entire device, not just your application.
The issue here is that the Google Search Application (4.1+) is controlling the beep and the audio, it is not part of the recognition API.
If you open Google Now whilst you have music playing and press the listen button, you'll note that the music stops until the recognition and voice interaction finishes, this is because the app is 'ducking' the audio.
There is nothing as developers we can do about this behaviour (other than use another Speech Recognition Provider) and it's frustrating, as voiced here.
Until we manage to persuade Google to allow us to pass parameters such as 'offline' and 'no audio prompt' in the Recognition Intent, there's nothing we can do but rant.....
I am making an app in which I've made a Service which plays Music from URLs. The thing is that my music Service is playing music correctly BUT when user plays any song with Native music player then BOTH(Native Player and My Music Service) are playing music simultaneously. I want to stop My Music Service when user started playing music with native player.
Is there any Broadcast Intent which i can register to Detect the
music player is started?
Is it possible to detect Music player Started?
Any Other Solution?
Any suggestions would appreciated.
I'll suggest a different approach, that I believe it's the correct approach.
the issue on your approach is that you're suggesting to check for one specific app. And there're tons of different music players, plus radio players, plus video players, plus games... and all of those should stop your music in case they want to play something.
So how you do it?
It's all explained in the Android Developers website.
You have to register an OnAudioFocusChangeListener, so, whenever a different app request to have the audio focus, your app can stop the music.
Step 1: Detect if the user has opened native music app. For this , you need to know the package name of your native music app.
Then refer to my answer here: Android how to know an app has been started and range apps priority according the starting times
Using that , the list taskinfo will have the list of all running activities, and as explained there, the first element of the list will be the activity in the foreground.
STEP 2: Once you detect native music app being activated using STEP 1 (by polling for it in the background) , then stop your app's service.
NOTE: You should do this in a background (using asynctask) or another service.
NOTE 2: The limitation of this method is that you can't actually stop the music player when the user clicks play in the native music app, since this method will help you detect only if the native music app is opened or not.
I' developing an Android app and in this app I've got a Android MediaPlayer and I want to ask, if I can access with this MediaPlayer to a running MediaPlayer, that was started by an other app?
For example I start a song with the Android Music app and the user opens my app. Is there a method to access and control this stream of the Android Music? So I can stop the music with stop() and start it start() and all the other functions?
If you are asking if there's a way to control a Media Player running in some other app from your app, then no. There is no way to do that.
If the other app is a service though, and that service allows control over its media player through intents, then you could control the other media player, but I'd be surprised if you got that lucky.
In my application I want to get start time of music player when user started and end time when it stops.I don't want to start any music player in my app. I just want to track user activity in device. So i want my application to get any notification when user started the music .
Do I get any intent for music player started and it stopped.Or do I get any intent for when user opens music files.
Is there any other method other than intent to capture the start time and and time when user starts music player.
Well you can implement the interface 'AudioManager.OnAudioFocusChangeListener' in which there is a method 'onAudioFocusChange' which lets you know if audio focus has been changed, and it can also tell if focus was gained or lost.
See this link, it explains the Audio Focus in detail. An application must gain audio focus through a request, and you can implement the 'AudioManager.OnAudioFocusChangeListener' and if there is focus gain, you can detect if the media player is running, (because some other application such as you tube may gain focus to play its audio), see this to see how to detect which application or service is currently running. You can find if audio has started to play, and if it was the media player or not.
Hope this helps. It was interesting question and I have learned some new things while searching for the answer!
Before open my application I played some of the music from default music player. With that background music I opened my application with the mediaplayer (android.media.MediaPlayer) to play the mp3 available in assets.
The default doesn't stop the music and I am getting two music concurrently from the device.
How do I stop or pause music of the default music player whenever my app started playing the music?
I think thats impossible. The default music player is a different app and out of your control. android does not allow controlling other app features from your app.
I had the same problem. I was trying to stop the background music of the default music player (if it is playing) when my VoIP SIP application receives an incoming call. I came up with:
AudioManager am = (AudioManager)getSystemService(Context.AUDIO_SERVICE);
am.setStreamMute(AudioManager.STREAM_MUSIC, true);
This does not stop or pause the music, but it make the music stream silent. Do not forget to unmute it later. This solution works well only if your second sound does not use the same stream.