我有两个声音片段,每次19秒,点击按钮1应该播放Soundclip1,点击button2播放Soundclip1应该停止,Soundclip2应该开始播放.. 请帮帮我,我被卡住了。 我对此进行了很多研究,但我的问题是声音同时播放......
请.... 我已将此Android Media Player Wont Play After Stop和Stop the prevoius sound before starting a new sound in my android app
提及答案 0 :(得分:1)
试试这个 -
final MediaPlayer mp1 = MediaPlayer.create(this, R.raw.one);
final MediaPlayer mp2 = MediaPlayer.create(this, R.raw.two);
Button btn = (Button)this.findViewById (R.id.button1);
btn.setOnClickListener(new OnClickListener(){
@override
public void onClick(View v) {
mp1.start();
mp2.pause();
mp2.seekTo(0);
}
});
Button btn1 = (Button)this.findViewById (R.id.button2);
btn1.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
mp1.pause();
mp1.seekTo(0);
mp2.start();
}
});