Question by
Dangerstevey · Jun 30, 2016 at 02:40 AM ·
audiowebglstreaming
Can't Stream an Audio file from a website in a WebGL Build
I need to stream songs to a webgl build, to be hosted on my website. I've got the files hosted on there and it works in the editor. the files are .ogg. the file never seems to even load
[code=CSharp]using System.Collections;
public class MusicStreaming : MonoBehaviour {
public string url;
public AudioSource source;
// Use this for initialization
void Start () {
WWW www = new WWW (url);
source = GetComponent<AudioSource> ();
source.clip = www.GetAudioClip (true, true);
}
// Update is called once per frame
void Update () {
if (!source.isPlaying) {
if (source.clip.loadState == AudioDataLoadState.Loaded) {
print ("readytoPlay");
source.Play ();
}
}
}
}[/code]
Comment
Your answer
Follow this Question
Related Questions
overcome stereo pan in WebGL. No way to turn on mono audio? 0 Answers
Audio analysis in WebGL 1 Answer
How to download and stream AudioClip at the same time 1 Answer
Streaming audio with UnityWebRequest 0 Answers
Unity Build ignores audio spread 1 Answer