⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 VB源码,是初学者的福因.让你很快掌握VB编程
💻 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         =   "Form1"
   ClientHeight    =   975
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5100
   LinkTopic       =   "Form1"
   ScaleHeight     =   975
   ScaleWidth      =   5100
   StartUpPosition =   3  '窗口缺省
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   240
      Top             =   360
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.TextBox Text1 
      Height          =   270
      Left            =   360
      TabIndex        =   6
      Text            =   "Text1"
      Top             =   120
      Width           =   4455
   End
   Begin VB.CommandButton cmdStop 
      Caption         =   "停止"
      Height          =   375
      Left            =   4080
      TabIndex        =   5
      Top             =   480
      Width           =   855
   End
   Begin VB.CommandButton cmdNext 
      Caption         =   "下一曲"
      Height          =   375
      Left            =   3120
      TabIndex        =   4
      Top             =   480
      Width           =   855
   End
   Begin VB.CommandButton cmdContinue 
      Caption         =   "继续"
      Height          =   375
      Left            =   2160
      TabIndex        =   3
      Top             =   480
      Width           =   855
   End
   Begin VB.CommandButton cmdPause 
      Caption         =   "暂停"
      Height          =   375
      Left            =   1200
      TabIndex        =   2
      Top             =   480
      Width           =   855
   End
   Begin VB.CommandButton cmdPlay 
      Caption         =   "播放"
      Height          =   375
      Left            =   240
      TabIndex        =   1
      Top             =   480
      Width           =   855
   End
   Begin MediaPlayerCtl.MediaPlayer MediaPlayer1 
      Height          =   1455
      Left            =   4080
      TabIndex        =   0
      Top             =   0
      Width           =   975
      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          =   -290
      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 Form_Load()
    MediaPlayer1.Visible = False
    Text1.Text = "万能播放器(基于Media Player)"
    cmdPlay.BackColor = vbRed
    cmdPause.BackColor = vbRed
    cmdContinue.BackColor = vbRed
    cmdStop.BackColor = vbRed
    cmdNext.BackColor = vbRed
    cmdContinue.Enabled = False
    cmdPause.Enabled = False
    cmdStop.Enabled = False
End Sub

'播放
Private Sub cmdPlay_Click()
    Text1.SetFocus
    On Error GoTo handler
    With CommonDialog1
    '.Flags = cdlOFNAllowMultiselect
    .InitDir = App.Path
    .Filter = "Midi Files(*.mid)|*.mid|MP3 Files(*.mp3)|*.mp3|Wave Filse(*.wav)|*.wav|(*.m3u)|*.m3u|*.*|*.*"
    .FileName = ""
    .ShowOpen
    End With
    MediaPlayer1.FileName = CommonDialog1.FileName
    MediaPlayer1.Play
    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 cmdPause_Click()
    Text1.SetFocus
    MediaPlayer1.Pause
    cmdPause.Enabled = False
    cmdContinue.Enabled = True
End Sub

'继续播放
Private Sub cmdContinue_Click()
    Text1.SetFocus
    MediaPlayer1.Play
    cmdPlay.Enabled = False
    cmdPause.Enabled = True
    cmdContinue.Enabled = False
End Sub

'播放下一曲
Private Sub cmdNext_Click()
    On Error GoTo NextErr '播放非m3u文件时只能播放单曲
    MediaPlayer1.Next
Exit Sub
NextErr:
    MsgBox "现在正在播放单曲,没有一下曲。", vbOKOnly, "出错信息"
End Sub

'停止播放
Private Sub cmdStop_Click()
    MediaPlayer1.Stop
    cmdPlay.Enabled = True
    cmdPause.Enabled = False
    cmdContinue.Enabled = False
    cmdStop.Enabled = False
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -