I’m making kind of a radio and I want multiple audio clips to play when I press space. Lets say I have 3 different clips. I press space and the first one starts playing. When pressing space again the first one stops and the second starts. After third it goes back to first one, but here’s the tricky situation: the clip should continue from where I changed it to second clip. Same goes with all clips.
Can this be done with java?
Okay I managed to make a player which plays different songs when you press space and then returns to start. The continuation of the song isn’t that important but if you have any info it would nice to hear.
Here’s the code I use
var sound1: AudioClip;
var sound2: AudioClip;
var sound3: AudioClip;
var sound4: AudioClip;
private var radio = "off";
function Update(){
if(Input.GetKeyDown("space")){
if(radio == "off"){
radio = "sound1";
}
else if(radio == "sound1"){
radio = "sound2";
}
else if(radio == "sound2"){
radio = "sound3";
}
else if(radio == "sound3"){
radio = "sound4";
}
else if(radio == "sound4"){
radio = "sound1";
}
if(radio == "sound1"){
Debug.Log("sound is playing");
audio.clip = sound1;
audio.Play();
}
else if(radio == "sound2"){
audio.clip = sound2;
audio.Play();
}
else if(radio == "sound3"){
audio.clip = sound3;
audio.Play();
}
else if(radio == "sound4"){
audio.clip = sound4;
audio.Play();
}
}
}