android实现音频文件播放的方法

来源:互联网 发布:恩知中岛美雪 编辑:程序博客网 时间:2024/06/05 01:53

在自定义工具类里加入

private final static int sounds[]={R.raw.s1,R.raw.s2,R.raw.s3,R.raw.s4};private static MediaPlayer mediaplayer=null;  public static void playSound(Context context,int id)    {    mediaplayer = MediaPlayer.create(context, SocketConstant.sounds[id]);      mediaplayer.start();    }

在需要播放的地方加入

SocketConstant.playSound(PPTSoftwareActivity.this,0);


原创粉丝点击