public GazeControl(string ip, int port) : this() { gazemotions = new GazeMotion(ip, port); player = new AudioPlayerProxy(ip, port); gazemotions.type = GazeMotion.gazeType.intimacy; gazemotions.mode = GazeMotion.gazeMood.listening; }
private void Connect() { Console.WriteLine("Looking for NAO's host '" + robotAddress + "'..."); IPAddress[] ip = Dns.GetHostAddresses(robotAddress); if (ip.Length == 0) { Console.WriteLine("Unable to find host '" + robotAddress + "'"); Thread.Sleep(2000); } else { foreach (IPAddress i in ip) { if (i.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { ipAddress = i.ToString(); break; } } Console.WriteLine("Resolved '" + robotAddress + "' as " + ipAddress + "!"); audioProxy = new AudioPlayerProxy(ipAddress, 9559); Console.WriteLine("Created AudioPlayer proxy."); var files = Directory.EnumerateFiles(@"wav", "*.mp3", SearchOption.AllDirectories); sounds.Clear(); lstCategories.Invoke((MethodInvoker)(() => { lstCategories.Items.Clear(); lstFiles.Items.Clear(); lstCategories.SelectedItem = null; lstFiles.Enabled = false; btnPlayRandom.Enabled = false; })); foreach (string file in files) { string category = Path.GetDirectoryName(file).Substring(Path.GetDirectoryName(file).LastIndexOf(Path.DirectorySeparatorChar)+1); string sound = Path.GetFileNameWithoutExtension(file); if (!sounds.ContainsKey(category)) { sounds[category] = new Dictionary<string, int>(); lstCategories.Invoke((MethodInvoker)(() => { lstCategories.Items.Add(String.Format("[Shift+{0}]:{1}", (char) keyIndexes[lstCategories.Items.Count], category)); })); } int soundId = -1; try { soundId = audioProxy.loadFile("/var/persistent/home/nao/wav/" + category + "/" + sound + ".mp3"); Console.WriteLine("Loaded file '" + category + "/" + sound + ".mp3'"); }catch (Exception e) { Console.WriteLine("Unable to load file '" + category + "/" + sound + ".mp3': " + e.Message + (e.InnerException!=null?": " + e.InnerException.Message:"")); } if (soundId != -1) { sounds[category][sound] = soundId; } else if (sounds[category].ContainsKey(sound)) { sounds[category].Remove(sound); } } behaviorProxy = new BehaviorManagerProxy(ipAddress, 9559); Console.WriteLine("Created BehaviorManager proxy."); if (behaviorProxy.isBehaviorPresent(idleBehavior)) { if (!behaviorProxy.isBehaviorRunning(idleBehavior)) { behaviorProxy.post.runBehavior(idleBehavior); } } Status = NaoStatus.Standby; } }