There is such a method. He played melodies in a row by this example: https://stackoverflow.com/questions/7383387/setting-an-array-of-songs-using-mediaplayer It works like this: Melodies from the repro array. in order. You must match the melody and picture. That is, the soundsRawResId [idx] melody (r.raw.1) plays the animation at the element of the imageview arr_imageB 1 .startAnimation (anim);
public void playAllSongs() { idx = (idx + 1); if (idx >= 7) { idx = -1; playAllSongs(); } else { AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(soundsRawResIds[idx]); arr_imageB[idx].startAnimation(anim); try { mediaPlayer.reset(); mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength()); mediaPlayer.prepare(); mediaPlayer.start(); afd.close(); } catch (IllegalArgumentException e) { Log.e(TAG, "Unable to play audio queue do to exception: " + e.getMessage(), e); } catch (IllegalStateException e) { Log.e(TAG, "Unable to play audio queue do to exception: " + e.getMessage(), e); } catch (IOException e) { Log.e(TAG, "Unable to play audio queue do to exception: " + e.getMessage(), e); } } } Arrays:
//music
private int [] soundsRawResIds = new int[]{R.raw.1, R.raw.2, R.raw.3, R.raw.4, R.raw.5, R.raw.6, R.raw.7}; //изображения, инициализация for (int index = 0; index < buttonIds.length; index++) { arr_imageB[index] = (ImageView) rootViewB.findViewById(buttonIds[index]); }