I am currently trying to create an android app that plays a different sequence of sounds based on user input. Is there a simple way to play a sequence of sounds I have looked at mediaplayer and soundpool but it does not look like they where designed for sequential.
Thank you RandyFreak that is probably the better way. But I actually Ended up doing it a little differently.
I created a list of fileDescriptors pointing to sounds and added an oncomplete listener to mediaplayer. And every time the media player completed it's current sound it would play the first sound in the list and remove it from the list.
I came across this issue a few months ago.
How I overcame this was I created a different mediaplayer for each sound and played them in the order that I needed.
That would be the simplest method.
I hope this helps
RF
Related
I use Exoplayer 2.8 to show HLS videos in my app.
For fix time contents seekbar works perfectly, but its useless for live content.
I want to show seekbar for past 12 hours and use it for timeshift, how can I do that?
Update: seems like there is already existing solutions:
https://github.com/google/ExoPlayer/issues/87
https://github.com/jglanfield/ExoPlayer/tree/jdg-hls-rewind
You should take a look at TimeLine object and use it depending on you seekbar update logic.
Simple approach would be to store start time on your own in the code and then update it as frequent as you want with increasing playback and buffer.
More helpful answer would be if you would post some code that you already have, so anyone can guide you towards solution that will work for you.
does someone know what is the best way to implement the audio loop-back functionality in an android app?
I need to start recording sound and play that recorded sound through the headphones at the same time.
I was thinking of storing the recorded data in an buffer, and passing that buffer to mediaPlayer object within the while loop. What do you guys think, would it be feasible or is there a better approach to this(some lib,etc.)?
I would suggest you take a look at Exoplayer since it provides you ways to implement your custom data source by implementing DataSource class. So you can implement the DataSource to use a stream to play the audio. The documentation is a little vague on how to override it but if you are willing to invest a bit of time to look into exoplayer code you will easily figure it out. Though not exactly your scenarion here is one of the POCs to show how custom source can be implemented CustomDataSource
I need to play sound effects in my game such as jump, failed, shot etc.
So for this purpose I have selected SoundPool class. But there were some times when it lagged.
So I wonder what is correct way to use this class. I have tried to use play method in new thread, it seems work better but I don't know if I am correct.
Please advice how to use object of this class correctly for better performance.
Best way to implement Sound / Music into your game is by using Service component. Read this answer here for an example.
I want to make an android program to play several sounds from the raw folder.And each sound can be controlled by its own play/pause button and the other thing is, this program can run in background also(as a service) How do i do that please some one help me to do this I already tried this but it is not working.Any help would be appreciated...
I think it is better to use SoundPool class to manage multiple sounds at the same time.
For my application I need to play multiple tracks simultaneously and some kinf of listener to know when a track is finished.
SoundPool seems to be the obvious choice, but unfortunately I could't find a solution to get notified when a track ends.
I also thought about using multiple instances of Android's MediaPlayer, but I'm afraid of getting performance issues.
Are there any other options?
If you use MediaPlayer, you can use OnCompletionListener. It also has no problem of playing multiple tracks at the same time. Like gian1200 says. Try it, perhaps the performance is not really an issue.