public void TestMethod1()
        {
            using (var system = new LowLevelSystem(preInit: a => { a.Output = OutputMode.NoSound; }))
            {
                //Load a sound to play
                var sound = system.CreateStream(name: "Content/Front_Center.wav", mode: Mode.Default);

                // Begin playing the sound
                var channel = system.PlaySound(sound, null, false);

                bool flag = true;

                channel.SetCallback((type, data1, data2) =>
                {
                    if (type == ChannelControlCallbackType.End)
                    {
                        //Now that the sound is done, dispose it
                        //With issue #23 this should crash on mono
                        sound.Dispose();

                        flag = false;
                    }
                });

                //Loop until the flag is set to false
                while (flag)
                {
                    system.Update();
                }
            }
        }
Exemple #2
0
        protected void WaitForKeypress(Action reportAction = null)
        {
            var watch = Stopwatch.StartNew();

            if (reportAction != null)
            {
                reportAction();
            }

            while (!Console.KeyAvailable)
            {
                Thread.Sleep(50);

                if (_lowLevelSystem != null)
                {
                    _lowLevelSystem.Update();
                }
                if (_system != null)
                {
                    _system.Update();
                }

                if (watch.ElapsedMilliseconds >= 500)
                {
                    watch.Restart();

                    if (reportAction != null)
                    {
                        reportAction();
                    }
                }
            }

            // Flush
            while (Console.KeyAvailable)
            {
                Console.ReadKey(true);
            }

            if (reportAction != null)
            {
                reportAction();
            }
        }