Advertisement
Guest User

Untitled

a guest
May 30th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.74 KB | None | 0 0
  1. public void playAllSongs() {
  2. //переменная в которую заношу индекс соответ. мелодии
  3. idx = (idx + 1);
  4. if (idx >= 7) {
  5. idx = -1;
  6. playAllSongs();
  7. }
  8. else {
  9. //массив мелодий
  10. AssetFileDescriptor afd = getContext().getResources().openRawResourceFd(soundsRawResIds[idx]);
  11.  
  12.  
  13.  
  14. try {
  15. mediaPlayer.reset();
  16. mediaPlayer.setDataSource(afd.getFileDescriptor(), afd.getStartOffset(), afd.getDeclaredLength());
  17. mediaPlayer.prepare();
  18. mediaPlayer.start();
  19. afd.close();
  20. } catch (IllegalArgumentException e) {
  21. Log.e(TAG, "Unable to play audio queue do to exception: " + e.getMessage(), e);
  22. } catch (IllegalStateException e) {
  23. Log.e(TAG, "Unable to play audio queue do to exception: " + e.getMessage(), e);
  24. } catch (IOException e) {
  25. Log.e(TAG, "Unable to play audio queue do to exception: " + e.getMessage(), e);
  26. }
  27.  
  28.  
  29. }
  30. }
  31.  
  32. private int
  33. [] soundsRawResIds = new int[]{R.raw.1, R.raw.2, R.raw.3,
  34. R.raw.4, R.raw.5, R.raw.6, R.raw.7};
  35.  
  36. //изображения, инициализация
  37. for (int index = 0; index < buttonIds.length; index++) {
  38. arr_imageB[index] = (ImageView) rootViewB.findViewById(buttonIds[index]);
  39. }
  40. 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