vB中的Windows Media Player控件

用Windows Media Player 打开相同目录下MP3文件的全代码

参考代码如下

Private Sub File1_Click()
    WindowsMediaPlayer1.url = App.Path + "\" + File1.List(File1.ListIndex)
    WindowsMediaPlayer1.Controls.play
End Sub

Private Sub Form_Load()
    File1.Path = App.Path
End Sub

Private Sub WindowsMediaPlayer1_OpenStateChange(ByVal NewState As Long)
    WindowsMediaPlayer1.url = App.Path + "\1.mp3"
    WindowsMediaPlayer1.Controls.play
    'WindowsMediaPlayer1.controls.pause '暂停
    'Controls.currentPosition = 10 '设置当前播放未知
End Sub

温馨提示:答案为网友推荐,仅供参考
相似回答