// Use this for initialization public void Start() { audioClips = new List <AudioClip>(); string[] bgms = System.IO.Directory.GetFiles(Environment.CurrentDirectory.Replace("\\", "/") + "/" + "sound/bgm/"); foreach (string s in bgms) { if (System.IO.Path.GetExtension(s).ToLower() == ".mp3") { AudioClip add = Mp3Loader.LoadMp3(s); audioClips.Add(add); } } advantage = Mp3Loader.LoadMp3(Environment.CurrentDirectory.Replace("\\", "/") + "/" + "sound/song-advantage.mp3"); disAdvantage = Mp3Loader.LoadMp3(Environment.CurrentDirectory.Replace("\\", "/") + "/" + "sound/song-disadvantage.mp3"); menuClip = Mp3Loader.LoadMp3(Environment.CurrentDirectory.Replace("\\", "/") + "/" + "sound/song.mp3"); audioSource = gameObject.AddComponent <AudioSource>(); #if UNITY_IOS multiplier = 0.08f; #endif multiplier = 0.8f; //if (Program.I().setting != null && !Program.I().setting.isBGMMute.value) //{ // PlayAudioFile(0); //} }
IEnumerator GetAudioClipAsStream() { WWW www = new WWW(url); yield return(www); if (www.error != null) { Debug.Log(www.error); yield break; } Stream stream = new MemoryStream(www.bytes); MP3Info info = MP3Helper.ReadMP3Info(stream); audioSource.clip = Mp3Loader.LoadMp3(stream); if (audioSource.clip.length > 1) // check if the clip is loaded, mybe not that clever,ha.. { msg.text = "MP3 has been Loaded .. "; button.interactable = true; } if (!string.IsNullOrEmpty(info.Title)) // fill the title text { Debug.Log(info.ToString()); string name = info.Title.Trim(); title.text = name; detail.text = info.ToString(); } }
private IEnumerator LoadMP3() { yield return(null); audioClip = Mp3Loader.LoadMp3(soundFilePath.Substring(8, soundFilePath.Length - 8)); audioClip.name = Path.GetFileName(soundFilePath); PlayAudioFile(); }
void Start() { audioSource = GetComponent <AudioSource>(); MP3Info info = MP3Helper.ReadMP3Info(Path); audioSource.clip = Mp3Loader.LoadMp3(Path); if (!string.IsNullOrEmpty(info.Title)) { Debug.Log(info.ToString()); } //StartCoroutine(GetAudioClipAsStream()); }
IEnumerator GetAudioClipAsStream() { WWW www = new WWW(url); yield return(www); if (www.error != null) { Debug.Log(www.error); } Stream stream = new MemoryStream(www.bytes); audioSource.clip = Mp3Loader.LoadMp3(stream); }
private void LoadMp3File() { string Path = System.IO.Path.Combine(Application.dataPath, path); msg.text = "Start Load MP3 .."; MP3Info info = MP3Helper.ReadMP3Info(Path); audioSource.clip = Mp3Loader.LoadMp3(Path); if (audioSource.clip.length > 1) // check if the clip is loaded, mybe not that clever,ha.. { msg.text = "MP3 has been Loaded .. "; button.interactable = true; } if (!string.IsNullOrEmpty(info.Title)) // fill the title text { Debug.Log(info.ToString()); title.text = info.Title; detail.text = info.ToString(); } }