public void PlayMusic(AudioGroup group, int startSampleOffset = 0, int lengthInSamples = 0, bool bReplaceIfExists = false) { // TODO: Warn if channels/frequency not matching! // TODO: Validate AudioGroup (!group.IsEmpty())! if (!group.IsReady()) { group.InitLayerData(); } if (curMusic != null) { transMusic = group; transMusicTime = startSampleOffset; } else { curMusic = group; curMusicTime = startSampleOffset - 1; // -1 to get the initial sample. } group.RegisterKoreography(); if (!bus.PlayAudio(group, startSampleOffset, lengthInSamples, bReplaceIfExists)) { Debug.LogWarning("PlayMusic() failed with group: " + group + ", likely something already in the AudioBus?"); } }