0
点赞
收藏
分享

微信扫一扫

多个播放器的选择使用

泠之屋 2023-06-21 阅读 77


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;         
 } 
}

 

举报

相关推荐

0 条评论