Is it possible to play an MP3 file in Android as system sound?
My problem is that I am developing an application that should play different SMS tones when the application receives an SMS from a particular phonenumber.
In the way it is working right now, I'm using a combination of MediPlayer, AssetFileDescriptor and AudioManager to play the MP3 file, and it's working OK except for one big bug: if user has lowered the media volume to 0, the received sms will be missed because the MP3 cannot be heard.
So, it is possible to get a MP3 file to play using the system sound player? Or get the mediaplayer to use the system sound volume settings?
I think that your best shot it to work with the RingtoneManager
You need to add the sound you want to play first into the manager and then you can play it using an intend
Here is an explanation of how it can be done: https://stackoverflow.com/a/1287415/458365
Hope it helps.
Related
Actually i'm trying to play a sound inside my raw folder in the project,
The issue is that the device for which i'm developing the app doesn't support MediaPlayer and by following this guide in which the user use AudioTrack, the app just freeze every time the sound play.
So which should be the optimal alternative to MediaPlayer? The sounds i'm trying to play in my app are like "alert" sounds
I am making an android application in which I have to answer the call and then I want to play pre-recorded audio so that the person calling will hear this.
Is there any API or any library which can I use for this?
Can we do it through text-to-speech ?
Thank you
It is not possible to play audio during call in Android device.
Note: You can play back the audio data only to the standard output
device. Currently, that is the mobile device speaker or a Bluetooth
headset. You cannot play sound files in the conversation audio during
a call.
Link to android documentation
https://developer.android.com/guide/topics/media/mediaplayer
For more information
How to play an audio file on a voice call in android
Now like does the question says, I need a way to play a small sound that lasts for like 1 second or less to play really quickly/fast in my Xamarin Android app. I am using .mp3 files and MediaPlayer class, is there any way to get as fast as possible to play a particular sound?
I'm trying to develop an Android app where as soon as the text to speech is completed an audio file has to be played. How to do this?
If I didn't get wrong idea, you want to use text-to-speech to read some text and store the speech audio into phone in the meantime? And play the audio later?
Have you checked AudioRecordTest? You can record audio and then play it later. Worth to try but I don't think you can get a good quality from the microphone. Hope this helps:)
By the way, as far as I know, android only support to record from mic for unrooted phone, which you can check here. Let me know if you can record sound source from the android system.
I have found the solution and that is in the method onUtteranceCompletedListener() we can know whether the speech is stopped or not and then we can write the code to play the audio file
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