public void Stop() { lock (_commandLock) { if (_mediaPlayer != null) { InvokeOnPlayerThread(() => _mediaPlayer.Stop(TrackCompletionReason.Stop, null)); } } }
public void Stop() { lock (_commandLock) { if (_mediaPlayer != null) { _logger.Info("Invoke stop"); InvokeOnPlayerThread(() => _mediaPlayer.Stop(TrackCompletionReason.Stop, null)); _logger.Info("Invoke stop complete"); } } }
public void RunMainLoop() { ConsoleKeyInfo choice; PrintUI(); do { while (!Console.KeyAvailable) { if (needUIUpdate) { PrintUI(); needUIUpdate = false; } PrintSongPosition(); Thread.Sleep(100); } try { choice = Console.ReadKey(true); switch (char.ToLower(choice.KeyChar)) { case 'x': case 'q': return; case ' ': if (player.IsPlaying()) { player.Stop(); } else { player.Play(); } break; case 'n': PlayNext(true); break; case 's': PandoraStation newStation = ShowStationChooser(); if (newStation != null && newStation != musicBox.CurrentStation) { ShowWaitIcon(true); musicBox.CurrentStation = newStation; Settings.Default.LastStationId = musicBox.CurrentStation.Id; Settings.Default.Save(); PlayNext(false); ShowWaitIcon(false); } break; case '?': case 'h': showHelp = !showHelp; modalWindowDisplayed = showHelp; needUIUpdate = true; break; case '+': musicBox.RateSong(musicBox.CurrentSong, PandoraRating.Love); needUIUpdate = true; break; case '-': musicBox.RateSong(musicBox.CurrentSong, PandoraRating.Hate); PlayNext(true); break; case 'b': musicBox.TemporarilyBanSong(musicBox.CurrentSong); PlayNext(true); break; case 'p': PrintText(" ", 0, 7); Settings.Default.DisplayPosition = !Settings.Default.DisplayPosition; Settings.Default.Save(); break; } if (choice.Key == ConsoleKey.Escape) { if (showHelp) { showHelp = false; modalWindowDisplayed = false; needUIUpdate = true; } else { return; } } if (choice.Key == ConsoleKey.UpArrow) { player.Volume += 0.01; PrintVolume(); Settings.Default.Volume = player.Volume; Settings.Default.Save(); } if (choice.Key == ConsoleKey.DownArrow) { player.Volume -= 0.01; PrintVolume(); Settings.Default.Volume = player.Volume; Settings.Default.Save(); } if (choice.Key == ConsoleKey.RightArrow) { PlayNext(true); } } catch (PandoraException e) { PrintText(e.ErrorCode + ": " + e.Message, 0, Console.WindowHeight - 5, ConsoleColor.Red); } } while (true); }