private void Player_PlaybackStateChanged(object sender, EventArgs e) { switch (Player.State) { case NAudio.Wave.PlaybackState.Paused: case NAudio.Wave.PlaybackState.Stopped: Preview.Value = false; Recording.Value = false; GraphForm?.Close(); GraphForm = null; break; } }
private bool SetSong(string Path) { Preview.Value = false; Recording.Value = false; GraphForm?.Close(); GraphForm = null; if (Player != null) { Player.PlaybackStateChanged -= Player_PlaybackStateChanged; Player.Dispose(); Player = null; } try { _song = Path; if (!string.IsNullOrEmpty(_song)) { if (Args.UseNullOut) { Player = new MusicPlayer(_song, new AsyncNullOut()); } else { Player = new MusicPlayer(_song); } Player.PlaybackStateChanged += Player_PlaybackStateChanged; Player.Rate = (float)PRateS.Value; SeekBarS.Maximum = Player.Duration.TotalMilliseconds; SeekBarS.Value = 0; } return(true); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(@"音楽ファイルの読み込み、または再生デバイスの初期化に失敗しました。 mp3ファイルまたはsgsongファイルであることを確認してください。 またはWASAPI排他モードを利用するソフトがある場合はそのソフトを閉じてから読み込んでください -----メッセージ----- " + ex.Message + "\n-----スタックトレース-----\n" + ex.StackTrace); return(false); } }