一.音频
1.Mediaplayer
设置数据源的三种方式:应用自带的音频,SD卡中的音频、网络音频
MediaPlayer player=new MediaPlayer(); player=Mediaplayer.create( this,R.raw.XX); player=MediaPlayer.setDatasource("SD卡路径/网络路径");
设置按钮并添加监听事件,实现音乐的播放、暂停
2.SoundPool
soundPool sound=new soundPool(10,AndioManager,SYSEAM,0);
HashMap <Integer,Integer)map=new HashMap<>();
map.put(1, sound.load( this, R.raw.do,1); sound.play (map.get(1),1,1,0,0,1);
二.视频播放(MediaPlayer+SurfaceView)
Mediaplayer player= Mediaplayer.create( this, R.raw.XX);
play. setOnClickListener(){
SurfaceHolder holder=surfaceview. getHolder();
//获取surfaceview的管理器player.setDisplay (holder);//将player与holder关联