Android-SoundPool

来源:互联网 发布:dbaccess declare sql 编辑:程序博客网 时间:2024/06/06 01:32

版权声明:以前的Blog文章合并。原创作品,谢绝转载!否则将追究法律责任。


BG:当一个应用需要频繁使用某个短促音效的时候。


开发简介

创建SoundPool.SoundPool(int count,int soundType,int srcQuality)指定池的大小,声音类型,质量。

调用该对象的load()方法,其参数跟MediaPlayer差不多,最后一个参数int Priority暂时没有意义,默认写1。

调用play(int resourceID,float leftVolume,float rightolume,int priority,int loop,float rate)

对于多个资源 最好使用HashMap<Integer,Integer>加载

loop: 0表示没有循环 -1表示循环

rate:范围为 0.5-2


SoundPool soundPool=null;//init poolsoundPool=new SoundPool(5,AudioManager.STREAM_MUSIC,0);HashMap<Integer, Integer> soundMap=new HashMap<Integer, Integer>();//padding data in soundMapsoundMap.put(1,soundPool.load(this,R.raw.song, 1));//playsoundPool.play(soundMap.get(1),1,1,0,0,1);



0 0
原创粉丝点击