我有一个需要在WMP中获取当前歌曲的Forms应用程序。到目前为止,我的代码是:
Imports WMPLib
Public Class Form1
Dim wmp As WindowsMediaPlayer = New WindowsMediaPlayer
Dim playlist As IWMPPlaylist = wmp.mediaCollection.getAll()
Dim media As IWMPMedia = playlist.Item(100)
Private Sub next1_Click() Handles next1.Click
Label1.Text = media.getItemInfo("Title")
End Sub
End Class
正如所料,这获得了我的第100首歌曲的标题,它确实有效。但是,如果我尝试 Dim media As IWMPMedia = wmp.currentMedia 和 Label1.Text = media.getItemInfo(“Title”),我会收到NullReferenceException
我很确定这应该是可能的,因为它在MSDN文档中都有,我无法让它工作。