private void btnStart_Click(object sender, System.EventArgs e) { // If necessary, close the old file if (m_State == State.Stopped) { // Did the filename change? if (tbFileName.Text != m_play.FileName) { // File name changed, close the old file m_play.Dispose(); m_play = null; m_State = State.Uninit; btnSnap.Enabled = false; } } // If we have no file open if (m_play == null) { try { // Open the file, provide a handle to play it in m_play = new DxPlay(panel1, tbFileName.Text); // Let us know when the file is finished playing m_play.StopPlay += new DxPlay.DxPlayEvent(m_play_StopPlay); m_State = State.Stopped; } catch (COMException ce) { MessageBox.Show("Failed to open file: " + ce.Message, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } // If we were stopped, start if (m_State == State.Stopped) { btnStart.Text = "Stop"; m_play.Start(); btnSnap.Enabled = true; btnPause.Enabled = true; tbFileName.Enabled = false; m_State = State.Playing; } // If we are playing or paused, stop else if (m_State == State.Playing || m_State == State.Paused) { m_play.Stop(); btnPause.Enabled = false; tbFileName.Enabled = true; btnStart.Text = "Start"; btnPause.Text = "Pause"; m_State = State.Stopped; } }
private void btnStart_Click(object sender, System.EventArgs e) { // If we have no class open if (m_play == null) { try { m_play = new DxPlay(tbFileName.Text, panel1); m_play.Completed += new EventHandler(m_play_Completed); m_play.Start(); btnStart.Text = "Stop"; tbFileName.Enabled = false; } catch (COMException ce) { MessageBox.Show("Failed create DxPlay: " + ce.Message, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { m_play.Stop(); } }
private void btnStart_Click(object sender, System.EventArgs e) { // If we have no class open if (m_play == null) { try { m_play = new DxPlay(tbFileName.Text, panel1); m_play.Completed +=new EventHandler(m_play_Completed); m_play.Start(); btnStart.Text = "Stop"; tbFileName.Enabled = false; } catch(COMException ce) { MessageBox.Show("Failed create DxPlay: " + ce.Message, "Open Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { m_play.Stop(); } }