using System.Collections;
using System.Collections.Generic;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.Networking;
public class TestLoadAudio : MonoBehaviour {
void Start () {
StartCoroutine(GetAudioClip());
}
IEnumerator GetAudioClip () {
using (UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip("https://www.ytmp3.cn/down/76041.mp3", AudioType.MPEG)) {
yield return www.SendWebRequest();
if (www.isHttpError || www.isNetworkError) {
Debug.Log(www.error);
} else {
AudioClip myClip = DownloadHandlerAudioClip.GetContent(www);
var audioSource = gameObject.AddComponent<AudioSource>();
audioSource.clip = myClip;
audioSource.Play();
Debug.Log(myClip);
}
}
}
}