- Home /
Play .ogg from url?
Is there are a working way to play .ogg from server? I tried this two: using UnityEngine; using System.Collections;
public class audiofromserver : MonoBehaviour {
// Use this for initialization
void Start () {
StartCoroutine(LoadAudio("http://themusicman.ru/ball.ogg"));
}
// Update is called once per frame
void Update () {
}
IEnumerator LoadAudio(string url) {
WWW m_get = new WWW(url);
yield return m_get;
GetComponent<AudioSource>().audio.clip = m_get.audioClip;
audio.Play();
}
}
and #pragma strict
var url : String = "http://themusicman.ru/ball.ogg";
function Start () {
var www : WWW = new WWW (url); // start a download of the given URL
audio.clip = www.GetAudioClip(true, true); // 2D, streaming
audio.Play();
}
function Update () {
}
they load audio, but don't play it what I am doing wrong?
Comment