MediaPlayer stops playing the sounds - Android

前端 未结 2 604
北恋
北恋 2021-01-06 04:37

Here is a simple piano app and it works but there is a problem. After about 20 clicks (sometimes it is exactly 28 clicks) even I click the buttons it doesn\'t play any sound

2条回答
  •  隐瞒了意图╮
    2021-01-06 05:15

    simple way is to add onComplationListener

    mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
        @Override
        public void onCompletion(MediaPlayer p1) {
            p1.release();
        }
    });
    

提交回复
热议问题