vb获取歌曲时间


添加了一个wmp控件。想知道如何能获取精确到毫秒的时间
四、 AxWindowsMediaPlayer
该控件不是系统标准控件,需安装Windows Media Player, 安装Windows Media Player时选厅铅择默认安装,在调出的“选择工具箱项”对话框的“COM组件”选项卡中有一个名为Windows Media Player的项目,将其添加到工具栏便可使用。
AxWindowsMediaPlayer1.URL = "c:\回家.mpg" '设置播液伏尘放文件
AxWindowsMediaPlayer1.settings.volume =50 '闹禅设置音量为50
AxWindowsMediaPlayer1.Ctlcontrols.play() '播放
AxWindowsMediaPlayer1.Ctlcontrols. pause () '暂停
AxWindowsMediaPlayer1.fullScreen = True '全屏播放
AxWindowsMediaPlayer1.settings.balance = 100 '选择左声道
AxWindowsMediaPlayer1.settings.balance = 0 '选择立体道
AxWindowsMediaPlayer1.settings.balance = -100 '选择右声道
AxWindowsMediaPlayer1.fullScreen = True '全屏播放
Label1.Text = AxWindowsMediaPlayer1.currentMedia.durationString '媒体总长度,格式为05:56
Label1.Text = "文件总长度:" & AxWindowsMediaPlayer1.currentMedia.duration() '单位为秒,格式为:241.1075663
Label1.Text = "当前播放时间:" & AxWindowsMediaPlayer1.Ctlcontrols.currentPosition '单位为秒,格式为:10.3172578
AxWindowsMediaPlayer1.Ctlcontrols.currentPosition = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition – 10'后退10秒
AxWindowsMediaPlayer1.settings.mute = True '设置为静音
AxWindowsMediaPlayer1.settings.volume = TrackBar1.Value '设置音量
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
'该过程用于循环播放
Dim a As Int16 = AxWindowsMediaPlayer1.currentMedia.duration() '单位为秒,格式为:241.1075663
Dim b As Int16 = AxWindowsMediaPlayer1.Ctlcontrols.currentPosition '单位为秒,格式为:10.3172578
If b = a Then
AxWindowsMediaPlayer1.Ctlcontrols.stop()
AxWindowsMediaPlayer1.Ctlcontrols.play()
End If
End Sub
以上代码在VB.NET,windows XP 中测试通过