嘿我正在尝试学习android的音频部分。我打算做的很简单。我想播放一个音频文件半秒钟然后播放第二个音频文件。在第二个结束后我想继续在两者之间循环。就像我说我只是想学习这个,我找不到一个像样的教程。任何帮助都会很棒。 JG
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final MediaPlayer rMusic = MediaPlayer.create(MainActivity.this,R.raw.r);
final MediaPlayer cMusic = MediaPlayer.create(MainActivity.this,R.raw.c);
Button rockSong = (Button) findViewById(R.id.button1);
Button classSong = (Button) findViewById(R.id.button2);
Button play = (Button) findViewById(R.id.button3);
final TextView rock = (TextView) findViewById(R.id.textView2);
final TextView classical = (TextView) findViewById(R.id.textView3);
play.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
rMusic.seekTo(500);
rMusic.start();
if(rMusic.getDuration()==500);
cMusic.start();
}
});
}