public void Execute()
 {
     using (wasapiOut)
     {
         cd.Start();
     }
 }
 public void Execute()
 {
     using (_reader)
         using (_waveOut)
         {
             cd.Start();
         }
 }
        public void Execute()
        {
            // Using nested command patterns to simulate a console menu.
            CommandRespiratory cr = new CommandRespiratory();

            cr.AddCommand("play", typeof(PlayCommand), (string[] param) => new PlayCommand(_soundPlayer));
            cr.AddCommand("playlooping", typeof(PlayLoopingCommand), (string[] param) => new PlayLoopingCommand(_soundPlayer));
            cr.AddCommand("stop", typeof(StopCommand), (string[] param) => new StopCommand(_soundPlayer));

            CommandDirector cd = new CommandDirector(cr);

            cd.Title = "Windows SoundPlayer";
            cd.Start();

            _soundPlayer.Stop();
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            // Setting up commands.
            CommandRespiratory mainCommandRespiratory = new CommandRespiratory();

            mainCommandRespiratory.AddCommand(
                "windowssoundplayer",
                typeof(WindowsSoundPlayerDemoCommand),
                (string[] param) => new WindowsSoundPlayerDemoCommand());
            mainCommandRespiratory.AddCommand(
                "naudioplayback",
                typeof(NAudioPlaybackDemoCommand),
                (string[] param) => new NAudioPlaybackDemoCommand());
            mainCommandRespiratory.AddCommand(
                "simpleoscillation",
                typeof(SimpleOscillationDemoCommand),
                (string[] param) => new SimpleOscillationDemoCommand());

            CommandDirector mainCommandDirector = new CommandDirector(mainCommandRespiratory);

            mainCommandDirector.Title = "NAudio Demos";
            mainCommandDirector.Start();
        }