📄 mp3_frm.frm
字号:
Private Sub imglist_on_Click()
imglist_off.Visible = True
imglist_on.Visible = False
Me.Height = 1695
End Sub
Private Sub imglistexit_Click()
imglist_off.Visible = True
imglist_on.Visible = False
Me.Height = 1695
End Sub
Private Sub imgmin_Click()
'定义最小化窗体的参数
With t
.cbSize = Len(tb)
.hwnd = Picture1.hwnd
.uId = 1&
.uFlags = NIF_ICON Or NIF_TIP Or NIF_MESSAGE
.ucallbackMessage = WM_MOUSEMOVE
.hIcon = Me.Icon
.szTip = "My Winamp" & Chr$(0)
End With
Shell_NotifyIcon NIM_ADD, t
Me.Hide
App.TaskVisible = False
End Sub
Private Sub imgnext_off_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
imgnext_off.Visible = False
imgnext_on.Visible = True
If playingindex <> mp3list.ListCount - 1 Then
mp3index = mp3index + 1
playmp3
End If
If playingindex = mp3list.ListCount - 1 Then
If repeat = True Then
mp3index = 0
playmp3
If shuffle = True Then
'随机取歌
int_temp = Int((mp3list.ListCount - lowerbound + 1) * Rnd + 0)
filename = list(int_temp)
playmp3
End If
Else
stopmp3
End If
End If
End Sub
Private Sub imgnext_off_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
imgnext_off.Visible = True
imgnext_on.Visible = False
End Sub
Private Sub imgremove_off_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
imgremove_off.Visible = True
imgremove_on.Visible = False
If mp3list.ListCount <> 0 Then
End If
End Sub
Private Sub imgremove_off_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
imgremove_off.Visible = False
imgremove_on.Visible = True
Dim int_temp As Integer
If mp3index > mp3list.ListCount - 1 Or mp3index = -1 Then Exit Sub
mp3list.RemoveItem mp3index
list(mp3index) = ""
'如mp3list为空,则停止播放
If mp3list.ListCount = 0 Then
stopmp3
Else
'将mp3list的歌的列表名前数字减1
'If mp3index <> mp3list.ListCount - 1 Then
For I = mp3index To mp3list.ListCount - 1
Dim lengthlist As Integer
Dim listnum As String
lengthlist = Len(mp3list.list(I))
listnum = Mid(mp3list.list(I), 1, 2) - 1
mp3list.list(I) = Format$(listnum, "00") & Mid(mp3list.list(I), 3, lengthlist - 2)
Next
'将list列表中的值向前==>list(i) = list(i + 1)
For I = 0 To 500
If list(I) = "" Then
For j = I To 499
list(j) = list(j + 1)
Next
Exit For
End If
Next
'End If
End If
If mp3list.ListCount <> 0 Then
If repeat = True Then
playmp3
End If
If shuffle = True Then
'随机取歌
int_temp = Int((mp3list.ListCount - lowerbound + 1) * Rnd + 0)
filename = list(int_temp)
playmp3
End If
Else
stopmp3
End If
End Sub
Private Sub imgrep_off_Click()
imgrep_off.Visible = False
imgrep_on.Visible = True
repeat = True
End Sub
Private Sub imgrep_on_Click()
imgrep_off.Visible = True
imgrep_on.Visible = False
repeat = False
End Sub
Private Sub imgshuf_off_Click()
imgshuf_off.Visible = False
imgshuf_on.Visible = True
shuffle = True
End Sub
Private Sub imgshuf_on_Click()
imgshuf_off.Visible = True
imgshuf_on.Visible = False
shuffle = False
End Sub
Private Sub imgopenfile_click()
Dim shortname As String
Dim mp3minute As Integer
Dim mp3second As Integer
Dim it As Integer
Dim lengthname As Integer
Dim shortfilename As String
Dim fullfilename As String
Dim temp_list As String
Dim nCount As Integer
Dim DlgInfo As DlgFileInfo
'通用对话框的初始
CDialog.InitDir = "D:\MP3\中国男歌手"
CDialog.DialogTitle = "选择MP3文件"
CDialog.filename = ""
CDialog.Flags = cdlOFNLongNames Or cdlOFNAllowMultiselect Or cdlOFNExplorer Or cdlOFNNoDereferenceLinks
'文件过滤
CDialog.Filter = "*.mp3;|*.mp3;"
CDialog.ShowOpen
imgopenfile.Visible = True
If CDialog.filename <> "" Then
DlgInfo = GetDlgSelectFileInfo(CDialog.filename)
For I = 1 To DlgInfo.iCount
fullfilename = Trim(DlgInfo.sPath & DlgInfo.sFile(I))
'获取短文件名
s = String(LenB(fullfilename), Chr(0))
GetShortPathName fullfilename, s, Len(s)
shortfilename = Left(s, InStr(s, Chr(0)) - 1)
'将短文件名加入list数组
list(mp3list.ListCount) = shortfilename
'打开mp3文件
mciSendString "close MEDIA", 0, 0, 0
mciSendString "open " & shortfilename & " alias MEDIA", 0, 0, 0
'计算mp3文件的播放时间
totalsec = String(256, Chr(0))
mciSendString "status MEDIA length", totalsec, Len(totalsec), 0
mp3minute = Int(Val(totalsec) / 60000)
mp3second = Int((Val(totalsec) Mod 60000) / 1000)
'获取文件名的前缀
it = Len(fullfilename)
For j = 1 To it
If Mid(fullfilename, it - j + 1, 1) = "\" Then
shortname = Mid(fullfilename, it - j + 2, j - 5)
Exit For
End If
Next
mp3list.AddItem Format$(mp3list.ListCount + 1, "00") & "." & shortname
'加文件短名和时间加入列表中
'lengthname = Len(shortname)
'temp_list = shortname
'If lengthname > 10 Then
'mp3list.AddItem Mid(temp_list, 1, 16) & "... " & mp3minute & ":" & Format$(mp3second, "00")
'Else
'For i = lengthname To 30 - lengthname / 2
'temp_list = temp_list & " "
'Next
'temp_list = Format$(mp3list.ListCount + 1, "00") & "." & temp_list
'mp3list.AddItem temp_list & mp3minute & ":" & Format$(mp3second, "00")
'End If
imgdown_Click
Next
End If
End Sub
Private Sub imgstop_off_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
imgstop_off.Visible = False
imgstop_on.Visible = True
stopmp3
End Sub
Private Sub imgstop_off_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
imgstop_off.Visible = True
imgstop_on.Visible = False
End Sub
Private Sub imgprev_off_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
'播放前一首歌
imgprev_off.Visible = False
imgprev_on.Visible = True
If playingindex <> 0 Then
mp3index = mp3index - 1
playmp3
End If
If playingindex = 0 Then
If repeat = True Then
mp3index = mp3list.ListCount - 1
playmp3
If shuffle = True Then
'随机取歌
int_temp = Int((mp3list.ListCount - lowerbound + 1) * Rnd + 0)
filename = list(int_temp)
playmp3
End If
Else
stopmp3
End If
End If
End Sub
Private Sub imgprev_off_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
imgprev_off.Visible = True
imgprev_on.Visible = False
End Sub
Private Sub imgplay_off_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
imgplay_off.Visible = False
imgplay_on.Visible = True
If mp3index >= 0 Then
playmp3
End If
End Sub
Private Sub imgplay_off_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
imgplay_off.Visible = True
imgplay_on.Visible = False
End Sub
Private Sub imgpause_off_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
imgpause_off.Visible = False
imgpause_on.Visible = True
pausemp3
End Sub
Private Sub imgpause_off_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
imgpause_off.Visible = True
imgpause_on.Visible = False
End Sub
Private Sub imgtotil_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
'响应鼠标事件,获取当前鼠标座标发送给系统消息
If Button = 1 Then
Dim ReturnVal As Long
x = ReleaseCapture()
ReturnVal = SendMessage(hwnd, &HA1, 2, 0)
End If
End Sub
Private Sub imgup_Click()
SendMessage mp3list.hwnd, WM_VSCROLL, SB_LINEUP, 0
ShowScrollBar mp3list.hwnd, SB_VERT, False
End Sub
Private Sub mp3list_Click()
Dim I As Integer
For I = 0 To mp3list.ListCount - 1
If mp3list.Selected(I) = True Then
mp3index = I
End If
Next
End Sub
Private Sub mp3list_DblClick()
If mp3list.ListCount <> 0 Then
mp3list_Click
playmp3
End If
End Sub
Private Sub mp3list_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim lXPoint As Long
Dim lYPoint As Long
Dim lIndex As Long
If Button = 0 Then
lXPoint = CLng(x / Screen.TwipsPerPixelX)
lYPoint = CLng(y / Screen.TwipsPerPixelY)
'获得当前的光标所在的的屏幕位置确定标题位置
lIndex = SendMessage(mp3list.hwnd, LB_ITEMFROMPOINT, 0, ByVal ((lYPoint * 65536) + lXPoint))
'显示提示行或清除提示行
If (lIndex >= 0) And (lIndex <= mp3list.ListCount) Then
mp3list.tooltiptext = Mid(mp3list.list(lIndex), 1, 18)
Else
mp3list.tooltiptext = ""
End If
End If
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, x As Single, y As Single)
'响应鼠标事件,当鼠标位于任务栏上时作响应
If x = &H1E3C Then
Me.Show
t.cbSize = Len(t)
t.hwnd = Picture1.hwnd
t.uId = 1&
Shell_NotifyIcon NIM_DELETE, t
End If
End Sub
Private Sub playmp3()
If mp3index >= 0 Then
'获取要播放的文件名
filename = list(mp3index)
mciSendString "close MM", vbNullString, 0, 0
mciSendString "Open " & filename & " Alias MM", 0, 0, 0
'获取文件的时间长度
totalsec = String(256, Chr(0))
mciSendString "status MEDIA length", totalsec, Len(totalsec), 0
If Val(totalsec) <> 0 Then
ProgressBar1.Max = Val(totalsec)
End If
'开始播放mp3
mciSendString "Play MM", 0, 0, 0
playingindex = mp3index
'启用TIMER控件
ProgressBar1.Min = 0
imgplaying.Visible = True
'获取文件名前缀
it = Len(filename)
For I = 1 To it
If Mid(filename, it - I + 1, 1) = "\" Then
shortname = Mid(filename, it - I + 2, I - 5)
Exit For
End If
Next
labelmin = 0
labelsec = 0
labeltime = "00:00"
label_playing.Caption = mp3index + 1 & "." & shortname & " "
timer_repeat.Enabled = True
timer_labelplaying.Enabled = True
End If
End Sub
Private Sub pausemp3()
'暂停播放mp3
If mp3list.ListCount <> 0 Then
If pause = False Then
mciSendString "Pause MM", 0, 0, 0
pause = True
timer_repeat.Enabled = False
Else
mciSendString "Play MM", 0, 0, 0
pause = False
timer_repeat.Enabled = True
End If
End If
End Sub
Private Sub stopmp3()
'停止播放mp3
mciSendString "Stop MM", 0, 0, 0
mciSendString "Close MM", 0, 0, 0
playingmp3 = False
label_playing.Caption = ""
labeltime = "00:00"
imgplaying.Visible = False
timer_repeat.Enabled = False
timer_labelplaying.Enabled = False
End Sub
Private Sub timer_labelplaying_Timer()
'使当前正在播放中的文件名有滚动效果
I = Len(label_playing.Caption)
temp_label = Mid(label_playing.Caption, 1, 2)
label_playing.Caption = Mid(label_playing.Caption, 3, I - 2) & temp_label
End Sub
Private Sub timer_repeat_Timer()
On Error GoTo err1
'获取当前文件播放状态
s = String(256, Chr(0))
mciSendString "status MM mode", s, Len(s), 0
If Left(s, 7) = "stopped" Then
If playingindex = mp3list.ListCount - 1 Then
If repeat = True Then
mp3index = 0
playmp3
Else
stopmp3
End If
If repeat = True And shuffle = True Then
'随机取歌
int_temp = Int((mp3list.ListCount - lowerbound + 1) * Rnd + 0)
filename = list(int_temp)
playmp3
Else
stopmp3
End If
Else
If playingindex <> mp3list.ListCount - 1 Then
mp3index = mp3index + 1
playmp3
Else
stopmp3
End If
End If
Else
'显示播放时间
labelsec = labelsec + 1
If labelsec > 60 Then
labelmin = labelmin + 1
labelsec = 0
End If
labeltime = Format$(labelmin, "00") & ":" & Format$(labelsec, "00")
s = String(256, 0)
mciSendString "status MM position", s, Len(s), 0
ProgressBar1.Value = Val(s)
'设置进度条上的百分比
Dim temp As String
temp = (ProgressBar1.Value / ProgressBar1.Max) * 100
temp = Int(Val(temp))
If temp = "" Then
temp = 0
End If
End If
err1:
End Sub
Private Sub Timer1_Timer()
'For i = 1 To 100
'Circle (X(i), Y(i)), size(i), BackColor
'Y(i) = Y(i) + pace(i)
'If Y(i) >= Me.Height Then Y(i) = 0: X(i) = Int(Me.Width * Rnd)
'Circle (X(i), Y(i)), size(i)
'Next
End Sub
Private Sub Timer2_Timer()
If mp3list.ListCount >= 10 Then
imgup.Visible = True
imgdown.Visible = True
Else
imgup.Visible = False
imgdown.Visible = False
End If
End Sub
Private Sub volscroll_Scroll()
SetVol volscroll.Value / 32767
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -