vb制作mp3播放器

来源:百度知道 编辑:UC知道 时间:2024/05/18 16:43:13
MP3的播放、暂停、停止按钮怎么没法用?运行点击时出现Player播放器变量未定义,怎么会事???

这个行吗?
Dim lv As Long, rv As Long

Private Sub Command1_Click()
Dim totaltimes As Long

Dim mp3file As String, it As Integer
Dim i As Integer
Mp3Play1.Close
CommonDialog1.ShowOpen
it = Len(CommonDialog1.FileName)
For i = 1 To it
If Mid(CommonDialog1.FileName, it - i + 1, 1) = "\" Then
mp3file = Mid(CommonDialog1.FileName, it - i + 2, i - 5)
Exit For
End If
DoEvents
Next i
Err = Mp3Play1.Open(CommonDialog1.FileName, "")
totaltimes = Mp3Play1.TotalTime
Label3.Caption = Str$(totaltimes \ 60000) & _
"分 " & Str$((totaltimes Mod 60000) / 1000) & "秒"
Label2.Caption = mp3file
Label5.Caption = Str$(Mp3Play1.BitRate / 1000) & "kbps"
Label6.Caption = Str$(Mp3Play1.SampleFrequency / 1000) & "khz"
lv = Mp3Play1.GetVolumeLeft
rv = Mp3Play1.GetVolumeRight
End Sub