读书人

多个播放器的取舍使用

发布时间: 2012-09-22 21:54:54 作者: rapoo

多个播放器的选择使用

public void PlayRingFile(View view) {          switch (view.getId()) {    case R.id.Button01:     if (mp2.isPlaying()) {        mp2.stop();    // stops the object from playing        mp2.release(); // always a good practice to release the resource      }     MediaPlayer mp1 = MediaPlayer.create(this.getApplicationContext(), R.raw.aaa);     mp1.start();     break;    case R.id.Button02:     if (mp1.isPlaying()) {        mp1.stop();    // stops the object from playing        mp1.release(); // always a good practice to release the resource      }     MediaPlayer mp2 = MediaPlayer.create(this.getApplicationContext(), R.raw.bbb);     mp2.start();     break;          } } 

?

读书人网 >移动开发

热点推荐