Пример #1
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();
        }
    }
Пример #2
0
    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();
        }
    }
Пример #3
0
    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());
    }