音乐播放器(VB编程源代码)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
音乐播放器设计一、先来欣赏一下本音乐播放器的最终效果吧:
设计思路很简单,即下面两个窗体的设计。
二、主窗体(form1)界面设计如下:
主窗体(form1)代码如下:
Dim t As Integer, a As Boolean
Dim p As Integer, b, w As Boolean, one
Private Sub allclear_Click()
'清空播放列表
List1.Clear
WMP1.currentPlaylist.Clear
Form1.Caption = "无任何曲目"
End Sub
Private Sub allloop_Click()
'全部循环播放
Timer3.Enabled = False
allloop.Checked = True
oneloop.Checked = False
rand.Checked = False
rule.Checked = False
Call WMP1.settings.setMode("loop", True)
End Sub
Private Sub Form_Load()
'初始化
Form1.Height = 7800
w = False
allloop.Checked = False
oneloop.Checked = False
rand.Checked = False
rule.Checked = True
Label2.Caption = "00:00"
'第一次打开时创建文件
If Dir("filepath.text") = "" And Dir("C:\music.txt") = "" Then
Open "C:\filepath.txt" For Output As #1
Close #1
Open "C:\music.txt" For Output As #2
Close #2
End If
'读取文件
Open "C:\filepath.txt" For Input As #1
Open "C:\music.txt" For Input As #2
Do While Not EOF(1)
Input #1, X
Input #2, Y
If Dir(X) <> "" Then
List1.AddItem (List1.ListCount + 1) & "." & Y
Call WMP1.currentPlaylist.insertItem(WMP1.currentPlaylist.Count, WMP1.newMedia(X)) End If
Loop
Close #1
Close #2
'初始化
If List1.ListCount <> 0 Then List1.Selected(0) = True
Picture3(0).Width = 114
Picture3(0).Height = 52
Picture3(0).PaintPicture Picture2(0).Picture, 0, 0, 114, 52, 0, 0, 114, 52
Picture3(1).PaintPicture Picture2(2).Picture, 0, 0, 60, 52, 0, 0, 60, 52
Picture3(2).PaintPicture Picture2(3).Picture, 0, 0, 83, 52, 0, 0, 83, 52
Picture3(4).PaintPicture Picture2(5).Picture, 0, 0, 60, 52, 0, 0, 60, 52
Picture3(3).PaintPicture Picture2(4).Picture, 0, 0, 83, 52, 0, 0, 83, 52
Picture11.PaintPicture Picture12.Picture, 0, 0, 19, 23, 0, 0, 19, 23
a = False
Call WMP1.settings.setMode("shuffle", False) '初始设置为顺序播放
Label1.Caption = Mid(List1.List(0), InStr(List1.List(0), ".") + 1)
sd1.Value = 50 '音量设置为50%
End Sub
Private Sub List1_DblClick()
'双击播放
Call WMP1.Controls.playItem(WMP1.currentPlaylist.Item(List1.ListIndex))
a = True
t = 1
Picture3(0).PaintPicture Picture2(1).Picture, 0, 0, 114, 52, 0, 0, 114, 52
End Sub
Private Sub List1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If X > List1.Width - 430 Then
w = True
End If
End Sub
Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) '伸缩播放列表
If X > List1.Width - 430 And X < List1.Width - 330 Then
List1.MousePointer = 9
Else
List1.MousePointer = 0
End If
If w = True And X > 1500 And X < 5800 Then
List1.Width = X
End If
End Sub