使用按钮停止OpenFileDialog

时间:2013-09-07 06:59:52

标签: vb.net vb.net-2010

我有一个媒体播放器,我作为学校项目的一部分。我有一个按钮,按下后隐藏表格并显示另一个。我想要做的是让按钮也停止播放媒体文件。这是我的代码

Private Sub TxtName_Enter(ByVal sender As System.Object, ByVal e As FormClosingEventArgs) Handles MyBase.FormClosing
        e.Cancel = True
    End Sub

    Private Sub BtnBrowse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBrowse.Click
        With OpenFileDialog1
            .Title = "File Browser"
            .Filter = "Media Files (*.wmv;*.mp3)|*.wmv;*.mp3"
            .FileName = ""
            .CheckFileExists = True
        End With
        If OpenFileDialog1.ShowDialog = _
            Windows.Forms.DialogResult.OK Then
            AxWindowsMediaPlayer1.URL = _
            OpenFileDialog1.FileName
        End If
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBack.Click
        Me.Hide()
        ECoach.Show()

1 个答案:

答案 0 :(得分:0)

要开始/停止......您必须使用MediaPlayerCtrl.Ctlcontrols.OrderYouWish。那就是:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnBack.Click
     AxWindowsMediaPlayer1.Ctlcontrols.stop()
     Me.Hide()
     ECoach.Show()
 End Sub