private void btnOpen_Click(object sender, EventArgs e) { OpenFileDialog open = new OpenFileDialog(); open.Filter = "Wave File (*.wav)|*.wav"; if (open.ShowDialog() != DialogResult.OK) { return; } Wave = new WaveFileReader(open.FileName); if (selectedWave == 1) { fileName1 = open.FileName; cwvNumber1.WaveStream = wave; cwvNumber1.Painting(); cwvNumber1.FitToScreen(); cwvNumber1.WaveStream.Position = 0; cwvNumber1.Focus(); } else if (selectedWave == 2) { fileName2 = open.FileName; cwvNumber2.WaveStream = wave; cwvNumber2.Painting(); cwvNumber2.FitToScreen(); cwvNumber2.WaveStream.Position = 0; cwvNumber2.Focus(); } lbMax.Text = wave.TotalTime.Minutes.ToString() + ":" + wave.TotalTime.Seconds.ToString(); lbCur.Text = "0 : 0"; status = DEFINE.STATUS.READY; }
private void btnPlay_Click(object sender, EventArgs e) { if (status == DEFINE.STATUS.READY) { status = DEFINE.STATUS.RUNNING; output.Init(channel); output.Play(); if (selectedWave == 1) { cwvNumber1.Play(); cwvNumber1.Focus(); } else if (selectedWave == 2) { cwvNumber2.Play(); cwvNumber2.Focus(); } timer1.Interval = 100; timer1.Start(); } else if (status == DEFINE.STATUS.RUNNING) { status = DEFINE.STATUS.PAUSE; output.Pause(); if (selectedWave == 1) { cwvNumber1.Pause(); } else if (selectedWave == 2) { cwvNumber2.Pause(); } } else if (status == DEFINE.STATUS.PAUSE) { status = DEFINE.STATUS.RUNNING; output.Play(); if (selectedWave == 1) { cwvNumber1.Play(); } else if (selectedWave == 2) { cwvNumber2.Play(); } } }
private void timer1_Tick(object sender, EventArgs e) { if (output.PlaybackState == PlaybackState.Playing) { if (channel.Position > channel.Length) { status = DEFINE.STATUS.READY; channel.Position = 0; output.Stop(); output.Init(channel); if (selectedWave == 1) { cwvNumber1.WaveStream.Position = 0; } else if (selectedWave == 2) { cwvNumber2.WaveStream.Position = 0; } } lbCur.Text = wave.CurrentTime.Minutes.ToString() + ":" + wave.CurrentTime.Seconds.ToString(); } }