I am building an Android application and I want to play multiple audio files back to back. I have a lot of audio files so I don't want to load them at once but as they are needed. I also need a way to stop the continuous playback. So as input I have a File[] array of audio files and I need a way to start continuously playing and stop. I saw MediaPlayer as a way to play the audio files but I wasn't sure how to continuously play them and stop on demand.
The Media Playback API Guide contains everything you need to know. You can also check the RandomMusicPlayer included in the Android SDK samples.
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 want to play multiple audio files simultaneously in sync. I , file on the SD-Card, or a file in a specific folder). I want to be able to put a delay on the files and adjust the play rate.
I have looked MediaPlayer, MediaPlayer seems like the right path, but they are not synchronous multiple audio into single audio.
I am working on one small android application.With in that I have a requirement like audio recording with pause and resume options.I searched a lot in the Google,but I couldn't get anything related to that.
Somebody said that there is no default pause and resume functionality in android.
If you want that ,"you need to save that recorded audio file while click on pause button and save into your SD card.And you need to start again from the beginning when you click on resume button.At lost If you want to upload ,then you need to merge all the recorded files as one file then upload it".
I followed his suggestion,but there is no such related code for merging audio files of m4a format available in java/android.
Can anyone suggest me on this.
yes that's correct android audio recorder don't support pause you need to stop and start this
and merge all the files together to create a recording
You need to use the audiorecorder class the good example is here
Android : recording audio using audiorecord class play as fast forwarded
and you need to merge them as demostrated here
Merging pcm audio files
Hope this helps
I'm trying to play a couple of short audio files (ca. 2sec) in an Android App with the Media Player. They do play, but for some of them I get a click sound at the end (which differs from file to file).
There are no click-sounds when I play it on the PC, also I tried to convert it from .mp3 in .ogg and modified the soundfiles themselves, nothing helps, I think the problem is probably the Media PLayer.
For short audio files, like sound effects, I would use a SoundPool
Also see this question and answer here: The correct way to play short sounds Android?
I want to stream an audio mp3 file and then play it through android media player plus I also want to cache this file, so that mediaplayer don't have to stream for recently played tracks.
I have tried using prepareAsync method but it doesn't give me access to buffer content, so I have decided to stream the audio file myself and then pass it to the media player for playing. I have achieved this by following this article here but this approach has a problem i.e. while transferring the file to media player it goes into error mode which causes my player to behave inconsistently.
When media player enters its error mode it doesn't come out of it automatically so I am forced to create a new media player and then re-provide it the downloaded file, this workaround causes the user to experience an undesired pause in the song playing.
So, does any one have improved an version of code given in above link? or do they know a better solution to this problem or is there is actually a library for streaming an audio file in android?
Thanks
The link you provided looks like a less than ideal solution (not to mention outdated). What you probably want is a local proxy server that gives you access to byte data before the MediaPlayer gets it. See my answer here for a little more explanation.