1.声明
private SoundPool sp;
private int soundID_1;
private int streamID_1;
2.创建
sp =new SoundPool(10, AudioManager.STREAM_MUSIC,0);
soundID_1 =sp.load(getApplicationContext(), R.raw.yinyue2,1);
3.播放
streamID_1 =sp.play(soundID_1,0.8f,0.8f,1, -1,1.0f);
4.释放资源
sp.release();
音频文件放在res文件夹下的 raw文件夹里面(自己再res中创建raw文件夹)
![](https://img.haomeiwen.com/i7286447/e2ab1159ec4b9dbc.png)
网友评论