Hello everyone! Search used, but did not find a solution. In general: There is an array of tunes, such a plan:
mediaPlayers[0] = MediaPlayer.create(getActivity(), R.raw.a); Only 7 el. Array. And there are 7 imageview, which are also in the array
arr_imageB[0] = (ImageView) rootViewB.findViewById(R.id.b1); And here's the problem: I click on imageview [i], everything is played, All melodies are played, but when I select the previous imageview, I’m logging a message:
Call this method to stop the previous melody:
private void stopPlayerIfNeeded() { for (int i = 0; i < mediaPlayers.length; i++) { MediaPlayer mediaPlayer = mediaPlayers[i]; if (mediaPlayer.isPlaying()) { mediaPlayer.stop(); mediaPlayer.reset(); } } } Call example:
case R.id.b7: arr_imageB[6].setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Animation anim = AnimationUtils.loadAnimation(v.getContext(),R.anim.clickbutton); arr_imageB[6].startAnimation(anim); stopPlayerIfNeeded(); mediaPlayers[6].start(); The warning also hangs: Should have subtitle controller already set