📄 form1.frm
字号:
VERSION 5.00
Object = "{22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0"; "msdxm.ocx"
Begin VB.Form form1
Caption = "带记忆的MP3播放器"
ClientHeight = 3870
ClientLeft = 60
ClientTop = 345
ClientWidth = 5610
Icon = "form1.frx":0000
LinkTopic = "Form1"
ScaleHeight = 3870
ScaleWidth = 5610
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command2
Caption = "播放"
Height = 285
Left = 2940
TabIndex = 15
ToolTipText = "搜索当前驱动器中所有的MP3文件"
Top = 90
Width = 855
End
Begin VB.CommandButton Command4
Caption = "退 出"
Height = 285
Left = 4680
TabIndex = 7
ToolTipText = "退出程序"
Top = 90
Width = 855
End
Begin VB.CommandButton Command3
Caption = "保存"
Height = 285
Left = 3810
TabIndex = 6
ToolTipText = "将选择的MP3文件保存为列表文件(smplay.m3u)"
Top = 90
Width = 855
End
Begin VB.CommandButton Command1
Caption = "搜索"
Height = 285
Left = 2085
TabIndex = 5
ToolTipText = "搜索当前驱动器中所有的MP3文件"
Top = 90
Width = 855
End
Begin VB.DriveListBox Drive1
BackColor = &H00FFC0C0&
Height = 300
Left = 90
TabIndex = 1
ToolTipText = "选择MP3文件所在的驱动器"
Top = 75
Width = 1920
End
Begin VB.FileListBox File1
Height = 450
Left = 2265
Pattern = "*.mp3"
TabIndex = 3
Top = 3180
Visible = 0 'False
Width = 1605
End
Begin VB.DirListBox Dir1
Height = 510
Left = 4320
TabIndex = 2
Top = 3135
Visible = 0 'False
Width = 1845
End
Begin VB.ListBox dir2
Height = 420
Left = 3270
TabIndex = 0
Top = 2415
Visible = 0 'False
Width = 930
End
Begin VB.Frame Frame1
Height = 2715
Left = 30
TabIndex = 4
Top = 390
Width = 5535
Begin VB.CommandButton Command5
Caption = "全部选中"
Height = 525
Left = 2505
TabIndex = 13
Top = 285
Width = 585
End
Begin VB.CommandButton Command6
Caption = "全部清除"
Height = 525
Left = 2505
TabIndex = 12
Top = 870
Width = 585
End
Begin VB.CommandButton Command8
Caption = "清除选择"
Height = 525
Left = 2505
TabIndex = 11
Top = 2025
Width = 585
End
Begin VB.CommandButton Command7
Caption = "添加"
Height = 525
Left = 2505
TabIndex = 10
Top = 1455
Width = 585
End
Begin VB.ListBox List1
Height = 2400
Left = 120
TabIndex = 9
Top = 195
Width = 2295
End
Begin VB.ListBox List2
Height = 2400
Left = 3165
TabIndex = 8
Top = 210
Width = 2295
End
End
Begin MediaPlayerCtl.MediaPlayer MediaPlayer1
Height = 660
Left = 45
TabIndex = 14
Top = 3165
Width = 5505
AudioStream = -1
AutoSize = 0 'False
AutoStart = -1 'True
AnimationAtStart= -1 'True
AllowScan = -1 'True
AllowChangeDisplaySize= -1 'True
AutoRewind = 0 'False
Balance = 0
BaseURL = ""
BufferingTime = 5
CaptioningID = ""
ClickToPlay = -1 'True
CursorType = 0
CurrentPosition = -1
CurrentMarker = 0
DefaultFrame = ""
DisplayBackColor= 0
DisplayForeColor= 16777215
DisplayMode = 0
DisplaySize = 4
Enabled = -1 'True
EnableContextMenu= -1 'True
EnablePositionControls= -1 'True
EnableFullScreenControls= 0 'False
EnableTracker = -1 'True
Filename = ""
InvokeURLs = -1 'True
Language = -1
Mute = 0 'False
PlayCount = 1
PreviewMode = 0 'False
Rate = 1
SAMILang = ""
SAMIStyle = ""
SAMIFileName = ""
SelectionStart = -1
SelectionEnd = -1
SendOpenStateChangeEvents= -1 'True
SendWarningEvents= -1 'True
SendErrorEvents = -1 'True
SendKeyboardEvents= 0 'False
SendMouseClickEvents= 0 'False
SendMouseMoveEvents= 0 'False
SendPlayStateChangeEvents= -1 'True
ShowCaptioning = 0 'False
ShowControls = -1 'True
ShowAudioControls= -1 'True
ShowDisplay = 0 'False
ShowGotoBar = 0 'False
ShowPositionControls= -1 'True
ShowStatusBar = 0 'False
ShowTracker = -1 'True
TransparentAtStart= 0 'False
VideoBorderWidth= 0
VideoBorderColor= 0
VideoBorder3D = 0 'False
Volume = -600
WindowlessVideo = 0 'False
End
End
Attribute VB_Name = "form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
Dim file As Long
Dim mystring As String
Dim s As String
Dim strfilename As String
strfilename = App.Path & "\smplay.m3u"
file = FreeFile()
On Error Resume Next
Open strfilename For Input As #file
Do While Not EOF(file)
Line Input #file, mystring
If mystring <> "" Then List1.AddItem mystring
Loop
Close #file
End Sub
Private Sub List1_Click()
List2.AddItem (List1.Text)
End Sub
Private Sub List2_DblClick()
If List2.Text <> "" Then List2.RemoveItem (List2.ListIndex)
End Sub
Private Sub Command1_Click()
List1.Clear
Dir1.Path = Left(Drive1.Drive, 2) + "\"
File1.Path = Dir1.Path
For i = 0 To File1.ListCount - 1
List1.AddItem Dir1.Path + File1.List(i)
Next
For i = 0 To Dir1.ListCount - 1
dir2.AddItem Dir1.List(i)
Next
If i = 0 Then GoTo FiniShedPoint
sel = 0
start:
Dir1.Path = dir2.List(sel)
File1.Path = Dir1.Path
For i = 0 To Dir1.ListCount - 1
dir2.AddItem Dir1.List(i)
Next
For i = 0 To File1.ListCount - 1
List1.AddItem Dir1.Path + "\" + File1.List(i)
Next
sel = sel + 1
If sel < dir2.ListCount Then GoTo start
FiniShedPoint:
Drive_er:
Exit Sub
End Sub
Private Sub Command2_Click() '播放mp3音乐
List2.ListIndex = 0
MediaPlayer1.FileName = List2.Text
MediaPlayer1.AutoStart = True
End Sub
Private Sub Command3_Click() '保存mp3音乐
Dim FNum As Integer
Dim strfilename As String
Dim i As Integer
FNum = FreeFile
strfilename = App.Path & "\SmPlay.m3u"
If Dir(strfilename) <> "" Then Kill strfilename
Open strfilename For Output As #FNum
For i = 0 To List2.ListCount - 1
Print #FNum, List2.List(i)
Next
Close #FNum
MsgBox "保存MP3文件完成!"
Exit Sub
End Sub
Private Sub Command5_Click() '选中全部mp3音乐到播放列表
Dim i As Integer
For i = 0 To List1.ListCount - 1
List1.ListIndex = i
Next i
End Sub
Private Sub Command6_Click() '清除播放列表里所有mp3音乐
List2.Clear
End Sub
Private Sub Command7_Click() '添加选择曲目到播放列表
If List1.Text <> "" Then List2.AddItem (List1.Text)
End Sub
Private Sub Command8_Click() '从播放列表删除选择曲目
If List2.Text <> "" Then List2.RemoveItem (List2.ListIndex)
End Sub
Private Sub MediaPlayer1_PlayStateChange(ByVal OldState As Long, ByVal NewState As Long) '连续播放
If MediaPlayer1.PlayState = mpStopped Then
If List2.ListIndex < List2.ListCount - 1 Then
List2.ListIndex = List2.ListIndex + 1
MediaPlayer1.FileName = List2.Text
MediaPlayer1.AutoStart = True
Else
List2.ListIndex = 0
MediaPlayer1.FileName = List2.Text
MediaPlayer1.AutoStart = True
End If
End If
End Sub
Private Sub Command4_Click()
End
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -