Private Sub Command1_Click()
On Error GoTo dealerror
Me.CommonDialog1.DialogTitle = "打开CD曲目"
Me.CommonDialog1.FileTitle = "cd(*.cda)|*.cda"
Me.CommonDialog1.ShowOpen
Me.MMControl1.To = Val(Mid(Me.CommonDialog1.FileName, 9, 2))
Me.MMControl1.Track = Me.MMControl1.To
Me.MMControl1.Command = "seek"
Exit Sub
dealerror:
End Sub
Private Sub Form_Load()
Me.MMControl1.Command = "close"
Me.MMControl1.DeviceType = "cdaudio"
Me.MMControl1.Command = "open"
End Sub
Private Sub Form_Unload(Cancel As Integer)
Me.MMControl1.Command = "stop"
Me.MMControl1.Command = "close"
End Sub
Private Sub MMControl1_StatusUpdate()
Me.Label2.Caption = "第" & Me.MMControl1.Track & "曲"
End Sub
Option Explicit
Private Sub Command1_Click()
dlgctrl.CancelError = True
On Error GoTo errhandle
With dlgctrl
.DialogTitle = "打开"
.Filter = "*.MP3|*.mp3"
.ShowOpen
MMControl1.FileName = .FileName
MMControl1.Command = "open"
End With
frmmusic.Caption = "播放器" & MMControl1.FileName
MMControl1.TimeFormat = mciFormatMilliseconds
Text1.Text = Format((MMControl1.Length \ 1000) \ 60, "00") & ":" & Format((MMControl1.Length \ 1000) Mod 60, "00")
Exit Sub
errhandle:
Exit Sub
End Sub
Private Sub Command2_Click()
Static lrcshow As Boolean
If lrcshow Then
lrcshow = False
frmlrc.Hide
Else
lrcshow = True
frmlrc.Show
End If
End Sub
Private Sub Command3_Click()
Form1.Show
frmmusic.Hide
End Sub
Private Sub Form_Load()
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "mpegvideo"
MMControl1.Command = "open"
MMControl1.TimeFormat = mciFormatMilliseconds
End Sub
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "close"
Unload frmlrc
End Sub
Private Sub MMControl1_PauseClick(Cancel As Integer)
MMControl1.UpdateInterval = 0
End Sub
Private Sub MMControl1_PlayClick(Cancel As Integer)
If MMControl1.FileName = "" Then
MsgBox "您没有选择媒体文件!"
Exit Sub
End If
Command1.Enabled = False
MMControl1.UpdateInterval = 1000
End Sub
Private Sub MMControl1_StatusUpdate()
MMControl1.TimeFormat = mciFormatMilliseconds
Text2.Text = Format((MMControl1.Position \ 1000) \ 60, "00") & ":" & Format((MMControl1.Position \ 1000) Mod 60, "00")
If Text1.Text = Text2.Text Then
MMControl1.Command = "close"
Text1.Text = "00:00"
Text2.Text = "00:00"
Command1.Enabled = True
End If
End Sub
Private Sub MMControl1_StopClick(Cancel As Integer)
Text1.Text = "00:00"
Text2.Text = "00:00"
MMControl1.Command = "close"
Command1.Enabled = True
End Sub