I have five wav
file in raw folder android.
How I can play this with sequentially?
声明媒体播放器对象。
MediaPlayer objPlayer = MediaPlayer.create(this,Your Music File //ex:-R.raw.sleepaway);
那么您可以添加几个媒体播放器方法来控制媒体播放器的行为。
public int onStartCommand(Intent intent, int flags, int startId){
objPlayer.start();
Log.d(LOGCAT, "Media Player started!");
if(objPlayer.isLooping() != true){
Log.d(LOGCAT, "Problem in Playing Audio");
}
return 1;
}
public void onStop(){
objPlayer.stop();
objPlayer.release();
}
public void onPause(){
objPlayer.stop();
objPlayer.release();
}
您可以从 onStop 或 onPause 方法更改音频文件。并从新音频重新开始。