📄 12.11.frm
字号:
VERSION 5.00
Object = "{22D6F304-B0F6-11D0-94AB-0080C74C7E95}#1.0#0"; "msdxm.ocx"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "用MediaPlayer播放Mp3文件"
ClientHeight = 2235
ClientLeft = 60
ClientTop = 345
ClientWidth = 7830
LinkTopic = "Form1"
ScaleHeight = 2235
ScaleWidth = 7830
StartUpPosition = 3 'Windows Default
Begin MSComDlg.CommonDialog CommonDialog1
Left = 6600
Top = 1680
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.CommandButton CmdStop
Caption = "停止"
Height = 495
Left = 4680
TabIndex = 4
Top = 1320
Width = 1215
End
Begin VB.CommandButton CmdContinue
Caption = "继续"
Height = 495
Left = 3240
TabIndex = 3
Top = 1320
Width = 1215
End
Begin VB.CommandButton CmdPause
Caption = "暂停"
Height = 495
Left = 1680
TabIndex = 2
Top = 1320
Width = 1215
End
Begin VB.CommandButton CmdPlay
Caption = "播放"
Height = 495
Left = 120
TabIndex = 1
Top = 1320
Width = 1215
End
Begin VB.TextBox Text1
BeginProperty Font
Name = "楷体_GB2312"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 120
TabIndex = 0
Top = 480
Width = 5895
End
Begin MediaPlayerCtl.MediaPlayer MediaPlayer1
Height = 495
Left = 6000
TabIndex = 5
Top = 480
Width = 1815
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 CmdContinue_Click() '继续
MediaPlayer1.Play
CmdPlay.Enabled = False
CmdPause.Enabled = True
CmdContinue.Enabled = False
Text1.Text = "正在播放:" & CommonDialog1.FileName
End Sub
Private Sub CmdPause_Click() '暂停
MediaPlayer1.Pause
CmdPause.Enabled = False
CmdContinue.Enabled = True
Text1.Text = "暂停播放:" & CommonDialog1.FileName
End Sub
Private Sub CmdPlay_Click() '播放
Text1.SetFocus
On Error GoTo handler
With CommonDialog1
.InitDir = App.Path
.Filter = "Midi Files(*.mid)|*.mid|MP3 Files(*.mp3)|*.mp3|Wave Files(*.wav)|*.wav"
'支持多种文件格式
.FileName = ""
.ShowOpen
End With
MediaPlayer1.FileName = CommonDialog1.FileName
Text1.Text = "正在播放" & CommonDialog1.FileName
CmdPlay.Enabled = False
CmdPause.Enabled = True
CmdContinue.Enabled = False
CmdStop.Enabled = True
Exit Sub
handler:
MsgBox "你没有选择媒体文件!", vbOKOnly, "错误信息"
End Sub
Private Sub CmdStop_Click() '停止
MediaPlayer1.Stop
CmdPlay.Enabled = True
CmdPause.Enabled = False
CmdContinue.Enabled = False
CmdStop.Enabled = False
Text1.Text = "停止播放"
End Sub
Private Sub Form_Load()
MediaPlayer1.Visible = False
CmdContinue.Enabled = False
CmdPause.Enabled = False
CmdStop.Enabled = False
Text1.Text = ""
Text1.BackColor = vbBlue
Text1.ForeColor = vbYellow
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -