📄 例[15-5].frm
字号:
VERSION 5.00
Object = "{C1A8AF28-1257-101B-8FB0-0020AF039CA3}#1.1#0"; "MCI32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "ComDlg32.OCX"
Begin VB.Form Form1
Caption = "例[15-5]MP3播放器--吉祥三宝.mp3"
ClientHeight = 3285
ClientLeft = 60
ClientTop = 345
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 3285
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin MSComDlg.CommonDialog CD1
Left = 3840
Top = 120
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MCI.MMControl MC1
Height = 375
Left = 240
TabIndex = 6
Top = 2760
Width = 4335
_ExtentX = 7646
_ExtentY = 661
_Version = 393216
DeviceType = ""
FileName = ""
End
Begin VB.HScrollBar HS1
Height = 375
Left = 1920
TabIndex = 5
Top = 2280
Width = 2655
End
Begin VB.CommandButton Command1
Caption = "选择文件..."
Height = 375
Left = 240
TabIndex = 0
Top = 120
Width = 1455
End
Begin VB.Label Label6
BorderStyle = 1 'Fixed Single
Height = 375
Left = 1920
TabIndex = 9
Top = 1680
Width = 2295
End
Begin VB.Label Label4
BorderStyle = 1 'Fixed Single
Height = 375
Left = 1920
TabIndex = 8
Top = 1200
Width = 2295
End
Begin VB.Label Label2
BorderStyle = 1 'Fixed Single
Height = 375
Left = 1920
TabIndex = 7
Top = 720
Width = 2295
End
Begin VB.Label Label7
Caption = "播放位置:"
Height = 375
Left = 240
TabIndex = 4
Top = 2280
Width = 1215
End
Begin VB.Label Label5
Caption = "总播放时间:"
Height = 375
Left = 240
TabIndex = 3
Top = 1680
Width = 1335
End
Begin VB.Label Label3
Caption = "当前播放时间:"
Height = 375
Left = 240
TabIndex = 2
Top = 1200
Width = 1575
End
Begin VB.Label Label1
Caption = "当前播放文件:"
Height = 375
Left = 240
TabIndex = 1
Top = 720
Width = 1455
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Function sj(ms As Long) As String '将ms 转换成分、秒表现形式的函数
Dim sec As Integer, min As Integer
sec = ms / 1000
min = sec \ 60
sec = sec Mod 60
sj = Format(min, "00") & ":" & Format(sec, "00")
End Function
Private Sub Command1_Click()
CD1.Filter = "MP3歌曲文件|*.mp3" '设置打开文件类型
CD1.ShowOpen '调用打开对话框
MC1.Command = "close" '关闭以前可能打开的文件
MC1.DeviceType = "mpegvideo" '设置MP3播放器的设备类型
MC1.TimeFormat = mciFormatMilliseconds '设置时间格式为微秒
MC1.FileName = CD1.FileName
MC1.Command = "open" '打开mp3播放器
HS1.min = 0 '设置滚动条
HS1.Max = MC1.Length / 1000 '媒体文件的总长度(单位为秒)
HS1.LargeChange = 10 '设置滚动条步长
HS1.SmallChange = 2
Label2.Caption = CD1.FileTitle '显示文件名
Form1.Caption = "例[15-5] Mp3播放器--" & Label2.Caption
Label6.Caption = sj(MC1.Length) '总播放时间
MC1.UpdateInterval = 100 '更新时间间隔为100ms
MC1.Command = "Play" '播放mp3歌曲
End Sub
Private Sub Form_Unload(Cancel As Integer)
MC1.Command = "close" '关闭多媒体设备
End Sub
Private Sub MC1_StatusUpdate()
HS1.Value = MC1.Position / 1000 '以秒为单位
Label4.Caption = sj(MC1.Position) '当前播放时间
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -