Unity seems to be telling me that AudioSource.clip.time doesn’t exist? Does it? I know AudioSource.time does and I have AudioSource.clip.length working so why can’t I get AudioSource.clip.time to work?
I am trying to make an audiosource shuffle between songs. At the moment it can tell when the first song has ended by using the AudioSource.time but the problem is that after that it can’t tell when the next song has ended unless there was a way to get the AudioSource.clip.time. Any help would be super helpful because this is driving me insane!
using UnityEngine;
using System.Collections;
public class Juke : MonoBehaviour
{
public float time;
public AudioClip[] whopperBeats;
public AudioSource radioStation;
public int randomclipNumber;
public int lastTrack;
// Use this for initialization
void Start()
{
Tunes();
lastTrack = 481516;
}
void Tunes()
{
randomclipNumber = Random.Range(0, whopperBeats.Length);
radioStation.clip = whopperBeats[randomclipNumber];
radioStation.Play();
}
void Update ()
{
lastTrack = 0 + randomclipNumber;
if (randomclipNumber == lastTrack)
{
//Tunes();
print("Re-Shuffle Initiated");
}
if (radioStation.clip.time >= radioStation.clip.length -1)
{
print("Play a new tasty beat.");
//Tunes();
}
}
}