I am trying to stream music from either the computer or the Internet for my game. I wrote the follow script but I cannot get either to work. I have the AudioSource and AudioListener in my scene. I checked that the song I am trying to play is mp3 and all Grooveshark songs are mp3.
using UnityEngine;
using System.IO;
using System.Collections;
public class streamer : MonoBehaviour {
public string internetmusic = "http://grooveshark.com/#!/s/You+Suffer/6IDpiD?src=5";
public string filemusic = "W:/Music/Childish Gambino/Because The Internet/01 The Library (Intro)";
private WWW music;
void Start () {
music = new WWW (filemusic);
}
void Update() {
if (music.isDone)
{
Debug.Log(music.isDone);
audio.clip = music.GetAudioClip (false, true, AudioType.MPEG);
this.enabled = false;
audio.Play ();
}
}
}
↧