美文网首页
SoundPool 播放音频文件

SoundPool 播放音频文件

作者: 啤酒小龙虾 | 来源:发表于2018-06-03 10:27 被阅读0次

    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文件夹)

    相关文章

      网友评论

          本文标题:SoundPool 播放音频文件

          本文链接:https://www.haomeiwen.com/subject/vqfjsftx.html