Advertisement
Guest User

Untitled

a guest
Jul 18th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. public void All()
  2. {
  3. for (int i = 0; i < tracks.Length; i++)
  4. {
  5. Transform itemm = Instantiate(item, grid);
  6. Transform child = itemm.GetChild(0);
  7. string name = " " + (i + 1) + ". " + tracks[i].name;
  8. child.GetComponent<Text>().text = name;
  9. child.GetComponent<Item>().track = tracks[i];
  10. if (source.isPlaying && tracks[i].name == source.clip.name)
  11. {
  12. child.GetComponent<Text>().fontStyle = FontStyle.Bold;
  13. name = name.Substring(name.IndexOf(". ") + 2);
  14. nameLabel.text = name;
  15. int hours = (int)(tracks[i].duration) / 3600;
  16. int seconds = (int)(tracks[i].duration) - (3600 * hours);
  17. int minutes = seconds / 60;
  18. seconds = seconds - (minutes * 60);
  19. string time = "";
  20. if (hours.ToString().Length != 2)
  21. time = "0" + hours.ToString();
  22. else
  23. time = hours.ToString();
  24. if (minutes.ToString().Length != 2)
  25. time += ":0" + minutes.ToString();
  26. else
  27. time += ":" + minutes.ToString();
  28. if (seconds.ToString().Length != 2)
  29. time += ":0" + seconds.ToString() + " ";
  30. else
  31. time += ":" + seconds.ToString() + " ";
  32. timeAllLabel.text = time;
  33. statusLabel.text = "Playing...";
  34. fill.enabled = true;
  35. handle.enabled = true;
  36. sldSeek.maxValue = tracks[i].duration;
  37. StopCoroutine("DownloadAndPlay");
  38. //StartCoroutine (SeekSlid ());
  39. }
  40. }
  41. if (!source.isPlaying)
  42. {
  43. nameLabel.text = "Music Player";
  44. statusLabel.text = "Ready";
  45. timeAllLabel.text = "00:00:00 ";
  46. timeNowLabel.text = " 00:00:00";
  47. }
  48. scr.value = 1;
  49. }
  50. IEnumerator SeekSlid()
  51. {
  52. while (source.isPlaying)
  53. {
  54. sldSeek.value = source.time;
  55. int hours = (int)(source.time) / 3600;
  56. int seconds = (int)(source.time) - (3600 * hours);
  57. int minutes = seconds / 60;
  58. seconds = seconds - (minutes * 60);
  59. string time = "";
  60. if (hours.ToString().Length != 2)
  61. time = " 0" + hours.ToString();
  62. else
  63. time = " " + hours.ToString();
  64. if (minutes.ToString().Length != 2)
  65. time += ":0" + minutes.ToString();
  66. else
  67. time += ":" + minutes.ToString();
  68. if (seconds.ToString().Length != 2)
  69. time += ":0" + seconds.ToString();
  70. else
  71. time += ":" + seconds.ToString();
  72. timeNowLabel.text = time;
  73. yield return new WaitForSeconds(1f);
  74. }
  75. }
  76. public void SliderSeek()
  77. {
  78. if (source.isPlaying)//или сейчас пауза
  79. source.time = (int)sldSeek.value;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement