I'm trying to loop a ~30 seconds audio track multiple times. I'm using a MediaPlayer to play the sounds, here is the code where its created:
mAnimalMediaPlayer = MediaPlayer.create(mContext, fish.getSound());
I then call:
mAnimalMediaPlayer.setLooping(true);
mAnimalMediaPlayer.start();
when a play button is clicked. When the track loops, there is a small but noticeable pause between the track ending and the new loop beginning. I am positive that the audio file im using does not contain any actual pause.
Here is an android bug report which has been up for some time: https://code.google.com/p/android/issues/detail?id=18756
I've tried a few workarounds (such as using .ogg files instead of .mp3) but the problem persists.
I'm looking for any possible workaround that will allow me to seamlessly loop the playback multiple times.
There is a very noticeable pause. However, I have just discovered through experimentation on an emulator running level 25 that if one prepares two identical players and alternately starts them one after the other when the other has finished then the gap becomes much more difficult to hear.
Related
I get popping sounds when simultaneously playing multiple SuperpoweredAudioPlayers. When one SuperpoweredAudioPlayer is playing a moderately loud sound, a popping sound gets made when I call play() on a second SuperpoweredAudioPlayer, even if there is initial silence in the second player and the process() volume is set to 0. I can't have pops in the output since I'm making a music production app. The output also needs to be generated in real time. Am I doing something wrong or is there a workaround? Would it be fixed by having the players in separate threads?
Separate threads are definitely not the solution, as all your audio processing should happen on the same thread. Two audio players are very low with CPU, you don't have a processing problem.
Perhaps you forgot to handle the return value of the process() function. If it's false, then it means silence, and the buffer is not updated (zeroed) at all.
Whenever I call setDisplay() on a MediaPlayer while it is playing (i.e. setDisplay(null) when backgrounding a video to play audio in the background) the media player stutters and rewinds for some small amount of time. Once I comment out these lines, essentially restricting the application to only play audio, these stutters and consequent rewinds no longer occur. Any ideas what the issue may be?
EDIT:
So I think the cause of the problem might be android media player choosing the closest keyframe to resume from on each display change because it can''t render inbetween keyframes. Any ideas?
I use jPlayer 2.7.1 (https://cdnjs.cloudflare.com/ajax/libs/jplayer/2.7.1/jquery.jplayer/jquery.jplayer.min.js) on my website to play audio tracks for users. The audio tracks come from an S3 bucket. Recently some users who access the website via an Android WebView that utilizes Chrome Mobile 30, 44, 45 are having issues playing the audio files.
The common complaint seems to be a variation of the track starting to play, and then at some point it gets stuck, skipping or lagging over the remaining audio. Some specific quotes from users:
"after several minutes the sound stop and repeat on the same word it
is like sort of lagging."
"when I press play, the recording plays in second snippets (sort of
like it is very slowly loading), very disjointed. The time bar also
does not progress, it just stays at 0:00 or sometimes to 0:01 and back
again, even though it's playing later parts of the recording."
"the audio plays a few seconds, stops, skips a lot of content, plays
for another second or two, stops, skips, and so on."
"If it does start it keeps cutting out/crackling sound and the time
doesn't start counting down."
Unfortunately I've been unable to recreate the issue myself.
What do you think could be causing this issue? Could moving to jPlayer 2.9.2 fix the issue?
their are some questions on stackoverflow about looping sound in android but neither gave me correct answer so i start new thread,
I want to loop a sound without gaps in android. I tried to use the code mediaplayer.setLooping(true) for mp3,ogg and wav file to loop the sound, but there is always a little pause when the first sound is over and the next sound start..my audio length is 2 min. and file size is more than 1 mb so i cant use soundpool for repeating sound.
i didn't know how to solve this issue.
Ok basically you have to create two objects of media player and then if time of first music is going to b finished then call the other one and your problem is solver
I have been attempting to play a bunch of sounds in my app as some views switch. The sound is narrative for the views and is between 3 and 10 seconds each, of which there are about 30.
First, I tried loading them all into a sound pool and passing it to a hashmap on program load, then I simply play them when required. This worked for the first 5 or 6 sounds but once I started to add more sounds to the sound pool, the later ones did not play. I assume this is due to the 1MB limit I have read about on soundpool.
I tried switching to just loading the sound and passing it straight to play on the next line however, no sounds play. Logcat just shows a reset and command cancelled for the player.
I switched then to loading the file and pointing to it with the hash map, however, even after doing an unload and loadimg a new sound at the same index it would just play the same sound every time.
I have tried MediaPlayer but it is ineffective for my desired application.
Can anyone suggest a way I should look to implement this properly? And should I be trying to load all sounds before hand or not?
I think you need to wait for the load to complete before you can play it. Add an onLoadCompleteListener and then play it when that is invoked.