Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void playAllSongs() {
- //переменная в которую заношу индекс соответ. мелодии
- idx = (idx + 1);
- if (idx >= 7) {
- idx = -1;
- playAllSongs();
- }
- else {
- //массив мелодий
- AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(soundsRawResIds[idx]);
- 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);
- }
- }
- }
- 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]);
- }
- private int[] buttonIds = new int[]{R.id.b1, R.id.b2, R.id.b3, R.id.b4, R.id.b5, R.id.b6, R.id.b7};
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement