- Home /
Question by
Julian_Spring · Dec 10, 2013 at 09:11 AM ·
arraysmusic
Music to array from specified path
I am making a music player, kinda. I have the filing working it will find the song in the specified file. I need to know how I could make it play the next song and I think it would be easier if we put it into an array?
var MusicFolder : System.IO.DirectoryInfo;
var myClip : WWW;
var myPath : String;
var playList : AudioClip[];
var i : int = 0;
function Start(){
myPath = "/Entertainment/Music/Count Your Blessings";
MusicFolder = new System.IO.DirectoryInfo(myPath);
myClip = new WWW("file:///" + MusicFolder.GetFiles()[i].FullName);
audio.clip = myClip.GetAudioClip(false, false);
i++;
}
function Update(){
if (!audio.isPlaying && audio.clip.isReadyToPlay)
{
audio.Play();
i++;
}
}
function PlayNext (){
if(audio.isPlaying){
i++;
MusicFolder = new System.IO.DirectoryInfo(myPath);
myClip = new WWW("file:///" + MusicFolder.GetFiles()[i].FullName);
audio.clip = myClip.GetAudioClip(false, false);
}
}
function OnGUI () {
var search : String;
// Make a text field that modifies stringToEdit.
search = GUI.TextField (Rect (10, 10, 200, 20),"myPath", 256);
}
Comment
Your answer
Follow this Question
Related Questions
check for click in rhythm game 0 Answers
transform array in javascript 2 Answers
problem accesing arrays 2 Answers
Multidimensional GameObject Arrays 1 Answer