Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public void All()
- {
- for (int i = 0; i < tracks.Length; i++)
- {
- Transform itemm = Instantiate(item, grid);
- Transform child = itemm.GetChild(0);
- string name = " " + (i + 1) + ". " + tracks[i].name;
- child.GetComponent<Text>().text = name;
- child.GetComponent<Item>().track = tracks[i];
- if (source.isPlaying && tracks[i].name == source.clip.name)
- {
- child.GetComponent<Text>().fontStyle = FontStyle.Bold;
- name = name.Substring(name.IndexOf(". ") + 2);
- nameLabel.text = name;
- int hours = (int)(tracks[i].duration) / 3600;
- int seconds = (int)(tracks[i].duration) - (3600 * hours);
- int minutes = seconds / 60;
- seconds = seconds - (minutes * 60);
- string time = "";
- if (hours.ToString().Length != 2)
- time = "0" + hours.ToString();
- else
- time = hours.ToString();
- if (minutes.ToString().Length != 2)
- time += ":0" + minutes.ToString();
- else
- time += ":" + minutes.ToString();
- if (seconds.ToString().Length != 2)
- time += ":0" + seconds.ToString() + " ";
- else
- time += ":" + seconds.ToString() + " ";
- timeAllLabel.text = time;
- statusLabel.text = "Playing...";
- fill.enabled = true;
- handle.enabled = true;
- sldSeek.maxValue = tracks[i].duration;
- StopCoroutine("DownloadAndPlay");
- //StartCoroutine (SeekSlid ());
- }
- }
- if (!source.isPlaying)
- {
- nameLabel.text = "Music Player";
- statusLabel.text = "Ready";
- timeAllLabel.text = "00:00:00 ";
- timeNowLabel.text = " 00:00:00";
- }
- scr.value = 1;
- }
- IEnumerator SeekSlid()
- {
- while (source.isPlaying)
- {
- sldSeek.value = source.time;
- int hours = (int)(source.time) / 3600;
- int seconds = (int)(source.time) - (3600 * hours);
- int minutes = seconds / 60;
- seconds = seconds - (minutes * 60);
- string time = "";
- if (hours.ToString().Length != 2)
- time = " 0" + hours.ToString();
- else
- time = " " + hours.ToString();
- if (minutes.ToString().Length != 2)
- time += ":0" + minutes.ToString();
- else
- time += ":" + minutes.ToString();
- if (seconds.ToString().Length != 2)
- time += ":0" + seconds.ToString();
- else
- time += ":" + seconds.ToString();
- timeNowLabel.text = time;
- yield return new WaitForSeconds(1f);
- }
- }
- public void SliderSeek()
- {
- if (source.isPlaying)//или сейчас пауза
- source.time = (int)sldSeek.value;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement