SoundPoolUtils-播放声音
来源:互联网 发布:java实现atm机形界面 编辑:程序博客网 时间:2024/04/30 03:41
SoundPoolUtils-播放声音
播放声音。
更新于:2015-08-10
import android.media.AudioManager;import android.media.SoundPool;public class SoundPoolUtils { private static SoundPool sp; /** * 播放一段声音 * * @param path 声音文件路径,如:/mnt/sdcard/abc/abc.mp3 * @return 播放声音的id */ public static int play(String path) { if (sp == null) { sp = new SoundPool(10, AudioManager.STREAM_MUSIC, 0); } int id = sp.load(path, 1); sp.setOnLoadCompleteListener(new SoundPool.OnLoadCompleteListener() { @Override public void onLoadComplete(SoundPool soundPool, int sampleId, int status) { soundPool.play(sampleId, 1f, 1f, 1, 0, 1); } }); return id; } /** * 停止播放 * * @param soundId 由play方法返回的id */ public static void stopSound(int soundId) { if (sp != null) { sp.stop(soundId); } } public static void release() { if (sp != null) { sp.release(); sp = null; } }}
0 0
- SoundPoolUtils-播放声音
- 播放声音
- 播放声音
- 播放声音
- 播放声音
- 播放声音
- IOS-播放声音,中断声音
- ios 播放声音 播放震动
- C#播放声音
- 播放器的声音
- VC++实现声音播放
- 如何播放声音
- nokia播放声音
- c#中播放声音
- moto声音播放
- C#中播放声音
- J2ME播放声音
- .net 声音播放
- Hibernate缓存管理
- 如何将pdf格式转换成txt
- 漫谈程序员(五)20年资深程序员编程经验分享
- JS中Cookie详解及示例展示
- Oracle同义词创建及其作用
- SoundPoolUtils-播放声音
- DVR/NVR解决方案
- 石子合并
- mybatis与spring3.1整合----
- poj 1182
- Makefile 使用总结
- 代码流程分析二:Settings-蓝牙分析-myDevice根preference分析
- DockerFile
- 天津90、北京54坐标和WGS84坐标