这个用VB6.0做的MP3怎么样才可以实现顺序播放,求高手赐招,代码如下
Public volum As Integer '定义声音全局变量,用于记录播放过程中的声音值Public bool As Boolean '定义全局变量
Dim xx As Integer
Dim yy As Integer
Dim fs As Integer
Private Sub Command14_Click()
Me.WindowState = vbMinimized
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
fs = 0
If X >= Me.Height - 200 And Y >= Me.Height - 200 Then fs = 1
xx = X
yy = Y
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button <> 1 Then Exit Sub
If fs = 0 Then
Me.Left = Me.Left - xx + X
Me.Top = Me.Top - yy + Y
Else
If Y < 5880 Then Y = 5880
If Y > 5880 Then Y = 5880
If X < 9825 Then X = 9825
If X > 9825 Then X = 9825
Me.Width = X
Me.Height = Y
End If
End Sub
Private Sub Check1_Click() '静音
If Check1.Value = 0 Then '如果没单击该按钮
WindowsMediaPlayer1.settings.mute = False '不暂停
Else
WindowsMediaPlayer1.settings.mute = True '暂停
End If
End Sub
Private Sub Command10_Click() '下一首
If File1.ListIndex = File1.ListCount - 1 Then '如果当前为最后一行
File1.ListIndex = 0 '多媒体列表中第一行成亮显
WindowsMediaPlayer1.Controls.Next '执行下一首操作
WindowsMediaPlayer1.URL = Dir1.Path & "\" & File1.FileName '播放路径
WindowsMediaPlayer1.Controls.play '播放音乐
Else
File1.ListIndex = File1.ListIndex + 1 '当前多媒体列表向下进1
WindowsMediaPlayer1.URL = Dir1.Path & "\" & File1.FileName '播放路径
volum = WindowsMediaPlayer1.settings.volume '声音值
WindowsMediaPlayer1.Controls.play '播放
End If
End Sub
Private Sub Command11_Click() '快进
Command1.Enabled = True '【播放】按钮可用
WindowsMediaPlayer1.Controls.fastForward '快进
End Sub
Private Sub Command12_Click() '快退
Command1.Enabled = True '【播放】按钮可用
WindowsMediaPlayer1.Controls.fastReverse '快退
End Sub
Private Sub Command13_Click()
Drive1.Visible = False '【驱动器列表】控件不可见
Dir1.Visible = False '【目录列表】控件不可见
Command13.Visible = False '【隐藏选择】按钮不可见
Command7.Enabled = True '【音乐选择】按钮可见
End Sub
Private Sub Command7_Click()
Drive1.Visible = True '【驱动器列表】控件可见
Dir1.Visible = True '【目录列表】控件可见
Command13.Visible = True '【隐藏选择】按钮可见
Command7.Enabled = False '【音乐选择】按钮不可见
End Sub
Private Sub Command9_Click() '上一首
If File1.ListIndex = 0 Then '如果当前多媒体列表为第一行
File1.ListIndex = File1.ListCount - 1 '多媒体列表变为最后一行显示
WindowsMediaPlayer1.Controls.previous '执行上一首操作
WindowsMediaPlayer1.URL = Dir1.Path & "\" & File1.FileName '播放路径
WindowsMediaPlayer1.Controls.play '播放
Else
File1.ListIndex = File1.ListIndex - 1 '选择上一首
WindowsMediaPlayer1.URL = Dir1.Path & "\" & File1.FileName '播放路径
volum = WindowsMediaPlayer1.settings.volume '声音值
WindowsMediaPlayer1.Controls.play '播放
End If
End Sub
Private Sub File1_DblClick()
WindowsMediaPlayer1.URL = Dir1.Path & "\" & File1.FileName '播放路径
volum = WindowsMediaPlayer1.settings.volume '声音值
WindowsMediaPlayer1.Controls.play '播放
Command2.Enabled = True '【暂停】按钮可用
Command3.Enabled = True '【停止】按钮可用
Command4.Enabled = True ' 【增音量】按钮可用
Command5.Enabled = True '【减音量】按钮可用
Command9.Enabled = True '【上一首】按钮可用
Command10.Enabled = True '【下一首】按钮可用
Command11.Enabled = True '【快进】按钮可用
Command12.Enabled = True '【快退】按钮可用
Check1.Enabled = True '【静音】按钮可用
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path '将文件列表框的路径值设置为目录列表框所选中的路径值
If File1.ListIndex < 0 Then '判断当前播放列表是否小于零
Exit Sub
Else
Command2.Enabled = True '【暂停】按钮可用
Command3.Enabled = True '【停止】按钮可用
Command4.Enabled = True ' 【增音量】按钮可用
Command5.Enabled = True '【减音量】按钮可用
Command9.Enabled = True '【上一首】按钮可用
Command10.Enabled = True '【下一首】按钮可用
Command11.Enabled = True '【快进】按钮可用
Command12.Enabled = True '【快退】按钮可用
Check1.Enabled = True '【静音】按钮可用
End If
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive '将驱动器列表中选中的当前驱动器赋给目录列表的路径
File1.Pattern = "*.mp3;*.MP3;*.wma" '只显示指定类型的音乐文件
End Sub
Private Sub Form_Load()
If File1.ListCount > 0 Then '如果启动窗体后,多媒体列表中存在音乐文件,各按钮控件可以操作
Command1.Enabled = False '【播放】按钮不可用
Command2.Enabled = True '【暂停】按钮可用
Command3.Enabled = True '【停止】按钮可用
Command4.Enabled = True ' 【增音量】按钮可用
Command5.Enabled = True '【减音量】按钮可用
Command9.Enabled = True '【上一首】按钮可用
Command10.Enabled = True '【下一首】按钮可用
Command11.Enabled = True '【快进】按钮可用
Command12.Enabled = True '【快退】按钮可用
Check1.Enabled = True '【静音】按钮可用
Command13.Visible = False '【隐藏选择】按钮不可见
Drive1.Visible = False '【驱动器列表】控件不可见
Dir1.Visible = False '【目录列表】控件不可见
File1.Pattern = "*.mp3;*.MP3;*.wma" '只显示指定类型的音乐文件
volum = WindowsMediaPlayer1.settings.volume '声音值
WindowsMediaPlayer1.Controls.play
Else '如果启动窗体后,没有多媒体列表
Command1.Enabled = False '【播放】按钮不可用
Command2.Enabled = False '【暂停】按钮不可用
Command3.Enabled = False '【停止】按钮不可用
Command4.Enabled = False '【增音量】按钮不可用
Command5.Enabled = False '【减音量】按钮不可用
Command13.Visible = False '【隐藏选择】按钮不可见
Command9.Enabled = False '【上一首】按钮不可用
Command10.Enabled = False '【下一首】按钮不可用
Command11.Enabled = False '【快进】按钮不可用
Command12.Enabled = False '【快退】按钮不可用
Check1.Enabled = False '【静音】按钮不可用
Drive1.Visible = False '【驱动器列表】控件不可见
Dir1.Visible = False '【目录列表】控件不可见
File1.Pattern = "*.mp3;*.MP3;*.wma" ''只显示指定类型的音乐文件
End If
End Sub
Private Sub Command1_Click() '播放
WindowsMediaPlayer1.Controls.play '允许播放
Command2.Enabled = True '【暂停】按钮可用
Command3.Enabled = True '【停止】按钮可用
End Sub
Private Sub Command2_Click() '暂停
bool = True
WindowsMediaPlayer1.Controls.pause '暂停
Command2.Enabled = False '【暂停】按钮不可用
Command3.Enabled = True '【停止】按钮可用
Command1.Enabled = True '【播放】按钮可用
End Sub
Private Sub Command3_Click() '停止播放
bool = True
WindowsMediaPlayer1.Controls.stop '停止
Command3.Enabled = False '【停止】按钮不可用
Command1.Enabled = True '【播放】按钮可用
Command2.Enabled = True '【暂停】按钮可用
End Sub
Private Sub Command4_Click() '增大音量
WindowsMediaPlayer1.settings.volume = WindowsMediaPlayer1.settings.volume + 5 '音量值增5个单位
volum = WindowsMediaPlayer1.settings.volume '获取新的音量
End Sub
Private Sub Command5_Click() '减小音量
WindowsMediaPlayer1.settings.volume = WindowsMediaPlayer1.settings.volume - 5 '音量值减5个单位
volum = WindowsMediaPlayer1.settings.volume '获取新的音量
End Sub
Private Sub Command8_Click() '退出程序
Unload Me '卸载窗体
End Sub
Private Sub WindowsMediaPlayer1_StatusChange() '循环播放实现
On Error Resume Next '发现错误暂不处理
If bool = False Then
WindowsMediaPlayer1.Controls.play '继续播放
End If
End Sub