public static void PlayFunc(IPlayable player1, IRecordable player2) { player1.Play(); Console.WriteLine("Please select the next command: record, pause or stop!"); string action = Console.ReadLine(); switch (action) { case "record": player2.Record(); RecordFunc(player1, player2); break; case "pause": player1.Pause(); Console.WriteLine("Please select your next step: stop or play again!"); string actionNext = Console.ReadLine(); switch (actionNext) { case "stop": player1.Stop(); break; case "play": PlayFunc(player1, player2); break; default: Console.WriteLine("Please select a valid command!"); break; } break; case "stop": player1.Stop(); break; default: Console.WriteLine("Please select a valid command!"); break; } }
static void Main(string[] args) { Console.Write("Select the mode: "); string mode = Console.ReadLine(); Player player = new Player(); switch (mode.ToLower()) { case "record": Console.WriteLine("Available action in this mode:"); IRecodable recodable = player as IRecodable; recodable.Record(); recodable.Pause(); recodable.Stop(); break; case "play": Console.WriteLine("Available action in this mode:"); IPlayable playable = player as IPlayable; playable.Play(); playable.Pause(); playable.Stop(); break; default: Console.WriteLine("The mode is not exist."); break; } }
public static void EnStop(this IPlayable playable) { if (playable.PlayState == PlayState.Playing) { playable.Stop(); } }
public static void Main(string[] args) { //создание экземпляра класса Player Player somePlayer = new Player(); //вызов метода Play из интерфейса IPlayable somePlayer.Play(); //upcast к интерфесу IPlayable IPlayable somePlayerAsIPlayable = somePlayer as IPlayable; //после upcast возможно вызвать методы Pause и Stop интерфеса IPlayable somePlayerAsIPlayable.Pause(); somePlayerAsIPlayable.Stop(); //вызов метода Record из интерфейса IRecordable somePlayer.Record(); //upcast к интерфесу IPlayable IRecordable somePlayerAsIRecordable = somePlayer as IRecordable; //после upcast возможно вызвать методы Pause и Stop интерфеса IPlayable somePlayerAsIRecordable.Pause(); somePlayerAsIRecordable.Stop(); }
static void ActionsInPlayer() { Player player = new Player(); Console.WriteLine("Выберите действие: 1 - воспроизвидение муз. 2 - запись звука"); int action = int.Parse(Console.ReadLine()); switch (action) { case 1: player.Play(); Console.WriteLine("Следующее действие муз.устройства: 1 - Пауза; 2 - Остановить; 3 - Выход;"); int newAction = int.Parse(Console.ReadLine()); IPlayable iPlayable = (IPlayable)player; switch (newAction) { case 1: iPlayable.Pause(); break; case 2: iPlayable.Stop(); break; case 3: break; } break; case 2: player.Record(); Console.WriteLine("Следующее действие записывающего устройства: 1 - Пауза; 2 - Остановить; 3 - Выход;"); int nextAction = int.Parse(Console.ReadLine()); IRecodable iRecodable = (IRecodable)player; switch (nextAction) { case 1: iRecodable.Pause(); break; case 2: iRecodable.Stop(); break; case 3: break; } break; default: Console.WriteLine("Ошибка выбора"); break; } }
public static void Toggle(this IPlayable playable) { if (playable.PlayState == PlayState.Paused) { playable.Start(); } else { playable.Stop(); } }
static void Main(string[] args) { Player player = new Player(); player.Record(); (player as IRecodable).Pause(); player.Play(); IPlayable playable = player; playable.Stop(); Console.ReadKey(); }
/// <summary> /// Stops the video /// </summary> /// <param name="button">Button to set styles to</param> public void Stop(Button button, IPlayable playable) { this.SwitchButtonStyle(button); if (CheckException.CheckNull(playable)) { this.MainScreenInstance.timerForRF.Stop(); playable.Stop(); } if (this.MainScreenInstance.timerForProgress.Enabled) { this.MainScreenInstance.timerForProgress.Stop(); this.MainScreenInstance.WriteVideoTime(); } }
static void Main(string[] args) { Player player = new Player(); IRecodable recodable = player as IRecodable; recodable.Record(); recodable.Pause(); recodable.Stop(); Console.WriteLine(new string('-', 50)); IPlayable playable = player as IPlayable; playable.Play(); playable.Pause(); playable.Stop(); }
static void Main(string[] args) { Player player = new Player(); IRecordable recordDevice = player; IPlayable playerDevice = player; recordDevice.Record(); recordDevice.Pause(); recordDevice.Stop(); playerDevice.Play(); playerDevice.Pause(); playerDevice.Stop(); Console.ReadLine(); }
static void Main(string[] args) { Player playAndRecord = new Player(); playAndRecord.Play(); IPlayable player = playAndRecord as IPlayable; player.Pause(); player.Stop(); playAndRecord.Record(); IRecordable recorder = playAndRecord as IRecordable; recorder.Pause(); recorder.Stop(); }
private static void Main(string[] args) { Player player = new Player(); IPlayable playPlayes = player; playPlayes.Play(); playPlayes.Pause(); playPlayes.Stop(); IRecodable recordPlayes = player; recordPlayes.Record(); recordPlayes.Pause(); recordPlayes.Stop(); Console.Read(); }
static void Main(string[] args) { Player player = new Player(); IPlayable music = player; music.Play(); music.Pause(); music.Stop(); IRecordable recorder = player; recorder.Record(); recorder.Pause(); recorder.Stop(); Console.ReadKey(); }
static void Main(string[] args) { Player player = new Player(); player.Play(); ((IPlayable)player).Pause(); // Явное приведение экземпляра класса к базовому интерфейсу - 1-й способ (player as IPlayable).Stop(); // Явное приведение экземпляра класса к базовому интерфейсу - 2-й способ IPlayable playerone = (IPlayable)player; // Явное приведение экземпляра класса к базовому интерфейсу - 3-й способ playerone.Stop(); Console.WriteLine(); player.Record(); ((IRecodable)player).Pause(); (player as IRecodable).Stop(); Console.ReadKey(); }
/* Створіть 2 інтерфейсу IPlayable і IRecodable. У кожному з інтерфейсів створіть по 3 методу * voidPlay () / voidPause () / voidStop () і voidRecord () / voidPause () / voidStop () відповідно. * Створіть похідний клас Player від базових інтерфейсів IPlayable і IRecodable. Написати програму, яка виконує програвання і запис.*/ static void Main(string[] args) { Player myPlay = new Player(); IPlayable myPlayer = myPlay as IPlayable; myPlayer.Play(); myPlayer.Pause(); myPlayer.Stop(); IRecodable myRecorder = myPlay as IRecodable; myRecorder.Record(); myRecorder.Pause(); myRecorder.Stop(); Console.ReadKey(); }
static void Main(string[] args) { Player player = new Player(); IRecordable irec = player; IPlayable ipl = player; irec.Record(); irec.Pause(); irec.Stop(); Console.WriteLine(); ipl.Play(); ipl.Pause(); ipl.Stop(); Console.WriteLine(); Console.ReadLine(); }
static void Main(string[] args) { Player player = new Player(); player.Play(); IPlayable player1 = player as IPlayable; player1?.Pause(); player1?.Stop(); Console.WriteLine(new string('-', 80)); player.Record(); IRecordable recorder1 = player as IRecordable; recorder1.Pause(); recorder1.Stop(); Console.ReadLine(); }
static void Main(string[] args) { Player player = new Player(); IPlayable ip = player as IPlayable; ip.Play(); ip.Pause(); ip.Stop(); Console.WriteLine(); IRecodable ir = player as IRecodable; ir.Record(); ir.Pause(); ir.Stop(); Console.ReadLine(); }
public static void Show(IPlayable player) { string answer = String.Empty; do { Console.WriteLine("Выберите действие с проигрыванием:"); Console.WriteLine("0 - Выход"); Console.WriteLine("1 - Проиграть музыку"); Console.WriteLine("2 - Приостановить музыку"); Console.WriteLine("3 - Остановить музыку"); answer = Console.ReadLine(); Console.WriteLine("\n"); switch (answer) { case "0": Console.WriteLine("Выполняем выход..."); break; case "1": player.Play(); break; case "2": player.Pause(); break; case "3": player.Stop(); break; default: Console.WriteLine("Некорректное действие, попробуйте еще раз..."); break; } Console.WriteLine("\n"); } while (answer != "0"); }
static void Main(string[] args) { Player player = new Player(); Console.WriteLine("***Player***"); IPlayable player1 = player; player1.Play(); player1.Pause(); player1.Stop(); Console.WriteLine(); Console.WriteLine("***Recorder***"); IRecordable recorder = player; recorder.Record(); recorder.Pause(); recorder.Stop(); Console.ReadKey(); }
/// <summary> /// Установить действия плеера в режиме проигрывания музики /// </summary> /// <param name="playerPlaying">Режим проигрывания музики</param> /// <param name="action"> Действие</param> private static void SetPlayingActions(IPlayable playerPlaying, int action) { switch (action) { case 1: { playerPlaying.Play(); break; } case 2: { playerPlaying.Pause(); break; } default: { playerPlaying.Stop(); break; } } }
static void Main(string[] args) { //1 Console.Write("Enter number document: "); int number = Int32.Parse(Console.ReadLine()); Console.Write("Document format\n" + "XML - X\n" + "TXT - T\n" + "DOC - D\n"); List <AbstractHandler> documents = new List <AbstractHandler>(); for (int i = 0; i < number; i++) { Console.Write("Enter formant for {0} document: ", i + 1); string format = Console.ReadLine(); if (format == "X") { documents.Add(new XMLHandler()); } else if (format == "T") { documents.Add(new TXTHandler()); } else if (format == "D") { documents.Add(new DOCHandler()); } } foreach (AbstractHandler doc in documents) { doc.Open(); doc.Create(); doc.Change(); doc.Save(); Console.WriteLine(); } //2 Player player = new Player(); player.Play(); IPlayable player1 = player as IPlayable; player1.Pause(); player1.Stop(); Console.WriteLine(); player.Record(); IRecodable player2 = player as IRecodable; player2.Pause(); player2.Stop(); Console.WriteLine(); //3 Title title = new Title { Text = "Good Book" }; Author author = new Author { Text = "Saska" }; Content content = new Content { Text = "Very long time ago!" }; Book book = new Book(title, author, content); book.Show(); Console.ReadLine(); }
static void Main(string[] args) { bool flag = true; int choice; Player player = new Player(); IPlayable playableMethods = player; IRecordable recordableMethods = player; Console.WriteLine("Добро пожаловать в плеер! Выберите, что вы хотите сделать:"); Console.WriteLine("1.Начать проигрывание"); Console.WriteLine("2.Поставить проигрывание на паузу"); Console.WriteLine("3.Остановить проигрыывание"); Console.WriteLine("4.Начать запись"); Console.WriteLine("5.Поставить запись на паузу"); Console.WriteLine("6.Остановить запись"); Console.WriteLine("7.Выключить"); while (flag) { choice = int.Parse(Console.ReadLine()); switch (choice) { case 1: player.Play(); Console.WriteLine("Выберете следующие действие:"); break; case 2: playableMethods.Pause(); Console.WriteLine("Выберете следующие действие:"); break; case 3: playableMethods.Stop(); Console.WriteLine("Выберете следующие действие:"); break; case 4: player.Record(); Console.WriteLine("Выберете следующие действие:"); break; case 5: recordableMethods.Pause(); Console.WriteLine("Выберете следующие действие:"); break; case 6: recordableMethods.Stop(); Console.WriteLine("Выберете следующие действие:"); break; case 7: Console.WriteLine("Выключение"); flag = false; break; default: Console.WriteLine("Неверный ввод!"); break; } } Console.ReadKey(); }
private void btPlayStop_Click(object sender, EventArgs e) => _player.Stop();
public static void StartMenu(Player player) { do { Console.Clear(); // First choice of user action byte firstChoice; Console.WriteLine((byte)FirstMenuItem.Play + ". Play"); Console.WriteLine((byte)FirstMenuItem.Record + ". Record"); Console.WriteLine((byte)FirstMenuItem.Exit + ". Exit"); Console.WriteLine("Make your choice:"); firstChoice = ReadChoice(); Console.Clear(); switch ((FirstMenuItem)firstChoice) { case FirstMenuItem.Play: // User chooses Play player.Play(); break; case FirstMenuItem.Record: // User chooses Record player.Record(); break; case FirstMenuItem.Exit: // User chooses Exit Environment.Exit(0); break; default: // User makes wrong choice break; } Console.WriteLine((byte)SecondMenuItem.Pause + ". Pause"); Console.WriteLine((byte)SecondMenuItem.Stop + ". Stop"); Console.WriteLine((byte)SecondMenuItem.Exit + ". Exit"); Console.WriteLine("Make your choice:"); // Second user choice in case Playing byte secondChoice = ReadChoice(); switch ((SecondMenuItem)secondChoice) { case SecondMenuItem.Pause: // User chooses Pause { if ((FirstMenuItem)firstChoice == FirstMenuItem.Play) // Playing { IPlayable iPlayable = player; iPlayable.Pause(); } else // Recording { IRecodable iRecodable = player; iRecodable.Pause(); } break; } case SecondMenuItem.Stop: // User chooses Stop { if ((FirstMenuItem)firstChoice == FirstMenuItem.Play) // Playing { IPlayable iPlayable = player; iPlayable.Stop(); } else { IRecodable iRecodable = player; // Recording iRecodable.Stop(); } break; } case SecondMenuItem.Exit: // User chooses Exit Environment.Exit(0); break; default: // User makes wrong choice break; } Console.ReadKey(); Console.Clear(); } while (true); }