unity3D 使用WWW 加载网络上的Mp3
2018-12-28 本文已影响0人
在夢里
public IEnumerator SendGet(string url)
{
WWW www = new WWW(url);
yield return www;
if (string.IsNullOrEmpty(www.error))
{
//GetComponent<AudioSource>().material.SetTexture("_MainTex", www.texture);
GetComponent<AudioSource>().clip = www.GetAudioClip(true, true, AudioType.MPEG);
GetComponent<AudioSource>().Play();
}
}
void Start()
{ string urlMusic = "http://fs.w.kugou.com/201812272129/79e6fa4013b917316b26c56f1180a60f/G127/M04/06/1B/vw0DAFwjaKmAVKRDADxB7o5uHSU509.mp3";
StartCoroutine(SendGet(urlMusic));
}
注意打成Apk,在移动端才有效