I am very beginner to Android programming, and I would like to learn how to use soundpool
method, I had search about it but all I found seems not easy to understand! I would like you to show me a very simple example that run 2 sounds.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Create a folder named as raw under
your_app/res/
. Then paste your ringtone in this folder, for exampleyour_app/res/ringtone.mp3
. Now use the following code:Be sure to release the SoundPool resources after use:
Here is a small, working example of
soundPool
, it is taken from here and slightly modified to match post 21 API's.One thing to notice is
maxStreams
, which indicates how many streams are allowed to run in parallel, if it is one(default), it can be removed from the builder.Yes. i went through this too. but for safety i have saved a piece of code i found online. Though havent used it, i know it will come in handy soon...
1) You need to create AudioAttributes object:
2) Create SoundPool object:
3) How to use SoundPool on all API levels example :
I have written a SoundPoolManager which can be used to load sound files and play as and when required. You can see it here.
Thanks.