E/MediaPlayer: error (1, -19)

前端 未结 2 946
后悔当初
后悔当初 2021-01-16 11:52

I\'m creating a simple soundboard to play sounds when a user clicks a button. Problem is, if the button is pressed enough ( usually around 10 times ) it will eventually stop

2条回答
  •  粉色の甜心
    2021-01-16 12:11

    private void playSound(int soundID){
      final MediaPlayer mp = MediaPlayer.create(this,soundID);
      mp.start();
      mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
            @Override
            public void onCompletion(MediaPlayer mediaPlayer) {
                mp.release();
            }
      });
    }
    

提交回复
热议问题