VB6.0播放音乐问题?
发布网友
发布时间:2023-12-03 07:18
我来回答
共1个回答
热心网友
时间:2024-12-12 14:06
用我这个思路:
'添加部件WindowsMediaPlayer1、五个按钮
Dim flag As Boolean
Private Sub Form_Load()
With WindowsMediaPlayer1
.uiMode = "full"
End With
Command1.Caption = "播放暂停"
Command2.Caption = "停止"
Command3.Caption = "快进"
Command4.Caption = "打开文件"
Command5.Caption = "快退"
End Sub
'播放暂停
Private Sub Command1_Click()
flag = Not flag
With WindowsMediaPlayer1
If flag = True Then
Command1.Caption = "pause"
.Controls.Play
Else
Command1.Caption = "play"
.Controls.pause
End If
End With
End Sub
'停止
Private Sub Command2_Click()
With WindowsMediaPlayer1
.Controls.Stop
End With
End Sub
'打开文件
Private Sub Command4_Click()
With CommonDialog1
.Filter = "avi (*.avi)|*.avi|mp3(*3.mp3)|*.mp3|所有格式(*.*)|*.*"
.ShowOpen
WindowsMediaPlayer1.URL = .FileName
'WindowsMediaPlayer1.Controls.Stop
Form1.Caption = .FileName
End With
End Sub
'快进
Private Sub Command3_Click()
With WindowsMediaPlayer1
.Controls.currentPosition = .Controls.currentPosition + 10
End With
End Sub
'快退
Private Sub Command5_Click()
With WindowsMediaPlayer1
.Controls.currentPosition = .Controls.currentPosition - 10
End With
End Sub