public Voice Play(AudioClip clip) { var playerIndex = -1; for (int i = 0; i < MaxPlayers && -1 == playerIndex; i++) { if (!_players[i].Done) { continue; } playerIndex = i; } if (-1 == playerIndex) { return(Voice.Error); } var player = _players[playerIndex]; player.Node.Stop(); _engine.DisconnectNodeOutput(player.Node); _engine.Connect(player.Node, _mixer, ((IOSAudioClip)clip).Format); player.PlayId++; player.Done = false; player.Node.Volume = 1.0f; player.Node.ScheduleBuffer(((IOSAudioClip)clip).Buffer, AVAudioPlayerNodeCompletionCallbackType.PlayedBack, player.Callback); player.Node.Play(); return(Voice.Create(player.Id, player.PlayId)); }