Exemple #1
0
        public static void PlayerRun()
        {
            AudioPlayer player = new AudioPlayer();

            player.ChangeState(new ReadyState(player));

            int  option;
            bool isExit = false;

            while (!isExit)
            {
                Console.WriteLine($"State Message: {player.GetStateMessage()}");
                Console.WriteLine($"Current Mode: {player.GetState()}");

                Console.WriteLine("Choose the option:");
                Console.WriteLine("1. Play/Stop");
                Console.WriteLine("2. Lock");
                Console.WriteLine("3. Next");
                Console.WriteLine("4. Previous");
                Console.WriteLine("5. Doubleclick - Next");
                Console.WriteLine("6. Doubleclick - Previous");
                Console.WriteLine("0. Exit");

                int.TryParse(Console.ReadLine(), out option);

                switch (option)
                {
                case 0:
                    isExit = true;
                    break;

                case 1:
                    player.ClickPlay();
                    break;

                case 2:
                    player.ClickLock();
                    break;

                case 3:
                    player.IsDoubleClick = false;
                    player.ClickNext();
                    break;

                case 4:
                    player.IsDoubleClick = false;
                    player.ClickPrevious();
                    break;

                case 5:
                    player.IsDoubleClick = true;
                    player.ClickNext();
                    break;

                case 6:
                    player.IsDoubleClick = true;
                    player.ClickNext();
                    break;
                }

                Console.Clear();
            }

            Console.WriteLine("Program ended.");
        }
Exemple #2
0
 public PlayingState(AudioPlayer player) : base(player)
 {
     this.player  = player;
     stateMessage = "Change to \"play\"";
 }
Exemple #3
0
 public LockedState(AudioPlayer player) : base(player)
 {
     this.player  = player;
     stateMessage = "Change to \"locked\"";
 }
Exemple #4
0
 public ReadyState(AudioPlayer player) : base(player)
 {
     this.player  = player;
     stateMessage = "Change to \"ready\"";
 }
Exemple #5
0
 public State(AudioPlayer player)
 {
     this.player = player;
 }