private static Player NewPlayer() { var player = new Player(); player.TrackPlayingStarter += (sender, eventArgs) => Console.WriteLine("Track {0} started.", eventArgs.EventInfo.Title); player.TrackPlayingFinished += (sender, eventArgs) => Console.WriteLine("Track {0} finished.", eventArgs.EventInfo.Title); return player; }
private static void ManagePlayer(Player player) { while (true) { DisplayPlayerCommandsInfo(); var cmd = GetCommand(); switch (cmd) { case "lo": case "load": Console.WriteLine("Enter path to the playlist:"); var path = Console.ReadLine(); if (string.IsNullOrWhiteSpace(path)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Invalid playlist path."); Console.ResetColor(); continue; } try { var pl = DataContractFormatter<Playlist>.Load(path); player.LoadPlayList(pl); Console.WriteLine("Playlist was loaded."); } catch (Exception) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Playlist loading error!"); Console.ResetColor(); } break; case "pl": case "play": player.Play(); break; case "pa": case "pause": player.Pause(); break; case "st": case "stop": player.Stop(); break; case "ne": case "next": player.NextTrack(); break; case "pr": case "previous": player.PreviousTrack(); break; case "in": case "info": DisplayPlayerCommandsInfo(); break; case "se": case "select": return; case "ex": case "exit": Environment.Exit(0); return; default: Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Error. Incorrect command."); Console.ResetColor(); continue; } } }