停止音板应用程序上的所有声音

时间:2016-04-25 18:54:58

标签: android-studio audio

我想制作一个音板应用程序,我想要它,所以如果我按下声音的按钮,它会先停止所有声音,但你是怎么做到的?

public class MainActivity extends AppCompatActivity {

    MediaPlayer smileMore;
    MediaPlayer intro;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        AdView mAdView = (AdView) findViewById(R.id.adView);
        AdRequest adRequest = new AdRequest.Builder().build();
        mAdView.loadAd(adRequest);

        smileMore = MediaPlayer.create(this,R.raw.smilemore);
        intro = MediaPlayer.create(this,R.raw.romanatwoodintro);
    }

    public void smileMoreBtn(View view) {
        smileMore.start();
    }

    public void introBtn(View view) {
        intro.start();
    }
}

0 个答案:

没有答案