private void ButtonPause(object sender, EventArgs e) { sound.Pause(); playing = false; }
private void ButtonPause(object sender, EventArgs e) { sound.Pause(); }
public SoundControl(JObject obj, OscTree.Tree oscParent, string soundPath, SoundGrid parentGrid) { InitializeComponent(); originalFileName = obj.ContainsKey("OriginalFileName") ? (string)obj["OriginalFileName"] : String.Empty; projectFileName = obj.ContainsKey("ProjectFileName") ? (string)obj["ProjectFileName"] : String.Empty; id = obj.ContainsKey("ID") ? (string)obj["ID"] : String.Empty; soundName = obj.ContainsKey("Name") ? (string)obj["Name"] : string.Empty; Loop = obj.ContainsKey("Loop") ? (bool)obj["Loop"] : false; this.parentGrid = parentGrid; this.DataContext = this; if (projectFileName != string.Empty) { sound = Yse.Yse.Handle.Interface.NewSound(); var path = System.IO.Path.Combine(soundPath, projectFileName); sound.Create(path, null, false, 1, true); sound.Doppler = false; PositionSlider.Minimum = 0; PositionSlider.Maximum = sound.Length; } osc = new OscTree.Object(new OscTree.Address(soundName, id), typeof(float)); oscParent.Add(osc); osc.Endpoints.Add(new OscTree.Endpoint("Play", (args) => { if (sound == null) { return; } if (args.Count() > 0) { try { if (Convert.ToBoolean(args[0]) == true) { sound.Play(); } else { sound.Stop(); } } catch (Exception) { sound.Play(); } } else { sound.Play(); } }, typeof(bool))); osc.Endpoints.Add(new OscTree.Endpoint("Restart", (args) => { if (sound == null) { return; } if (sound.Playing) { sound.Time = 0; } else { sound.Play(); } })); osc.Endpoints.Add(new OscTree.Endpoint("Stop", (args) => { if (sound == null) { return; } sound.Stop(); }, typeof(bool))); osc.Endpoints.Add(new OscTree.Endpoint("Pause", (args) => { if (sound == null) { return; } sound.Pause(); }, typeof(bool))); osc.Endpoints.Add(new OscTree.Endpoint("Time", (args) => { if (sound == null) { return; } if (args.Count() > 0) { sound.Time = Convert.ToSingle(args[0]); } }, typeof(float))); osc.Endpoints.Add(new OscTree.Endpoint("Volume", (args) => { if (sound == null) { return; } if (args.Count() > 0) { sound.Volume = Convert.ToSingle(args[0]); } }, typeof(float))); osc.Endpoints.Add(new OscTree.Endpoint("Speed", (args) => { if (sound == null) { return; } if (args.Count() > 0) { sound.Speed = Convert.ToSingle(args[0]); } }, typeof(float))); osc.Endpoints.Add(new OscTree.Endpoint("Loop", (args) => { if (sound == null) { return; } if (args.Count() > 0) { sound.Loop = Convert.ToBoolean(args[0]); } }, typeof(bool))); osc.Endpoints.Add(new OscTree.Endpoint("Pos", (args) => { if (sound == null) { return; } try { IYse.Pos pos = new IYse.Pos(); if (args.Count() > 1) { pos.X = Convert.ToSingle(args[0]) * 10; pos.Z = Convert.ToSingle(args[1]) * 10; } sound.SetPos(pos); } catch (Exception) { } }, typeof(object))); }