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

📄 mp3.vb

📁 这是一本用Visual Studio.NET进行多媒体编程的读物
💻 VB
字号:
Option Strict Off
Option Explicit On
Imports VB = Microsoft.VisualBasic
Friend Class mp3test
	Inherits System.Windows.Forms.Form
#Region "Windows 窗体设计器生成的代码"
	Public Sub New()
		MyBase.New()
		If m_vb6FormDefInstance Is Nothing Then
			If m_InitializingDefInstance Then
				m_vb6FormDefInstance = Me
			Else
				Try 
					'对于启动窗体,所创建的第一个实例为默认实例。
					If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
						m_vb6FormDefInstance = Me
					End If
				Catch
				End Try
			End If
		End If
		'此调用是 Windows 窗体设计器所必需的。
		InitializeComponent()
	End Sub
	'窗体重写处置,以清理组件列表。
	Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
		If Disposing Then
			If Not components Is Nothing Then
				components.Dispose()
			End If
		End If
		MyBase.Dispose(Disposing)
	End Sub
    Private components As System.ComponentModel.IContainer
	'Windows 窗体设计器所必需的
		Public ToolTip1 As System.Windows.Forms.ToolTip
    Public WithEvents Command2 As System.Windows.Forms.Button
    Public WithEvents Command1 As System.Windows.Forms.Button
	Public WithEvents Text1 As System.Windows.Forms.TextBox
	Public WithEvents Dir1 As Microsoft.VisualBasic.Compatibility.VB6.DirListBox
	Public WithEvents File1 As Microsoft.VisualBasic.Compatibility.VB6.FileListBox
	Public WithEvents Drive1 As Microsoft.VisualBasic.Compatibility.VB6.DriveListBox
	Public WithEvents ActiveMovie1 As AxMediaPlayer.AxMediaPlayer
	Public WithEvents Label1 As System.Windows.Forms.Label
    '注意:以下过程是 Windows 窗体设计器所必需的
    '可以使用 Windows 窗体设计器来修改它。
	'不要使用代码编辑器来修改它。
    Friend WithEvents Timer1 As System.Windows.Forms.Timer
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.components = New System.ComponentModel.Container()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(mp3test))
        Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
        Me.Dir1 = New Microsoft.VisualBasic.Compatibility.VB6.DirListBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Drive1 = New Microsoft.VisualBasic.Compatibility.VB6.DriveListBox()
        Me.Command1 = New System.Windows.Forms.Button()
        Me.File1 = New Microsoft.VisualBasic.Compatibility.VB6.FileListBox()
        Me.Command2 = New System.Windows.Forms.Button()
        Me.ActiveMovie1 = New AxMediaPlayer.AxMediaPlayer()
        Me.Text1 = New System.Windows.Forms.TextBox()
        Me.Timer1 = New System.Windows.Forms.Timer(Me.components)
        CType(Me.ActiveMovie1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'Dir1
        '
        Me.Dir1.BackColor = System.Drawing.SystemColors.Window
        Me.Dir1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Dir1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Dir1.IntegralHeight = False
        Me.Dir1.Location = New System.Drawing.Point(8, 176)
        Me.Dir1.Name = "Dir1"
        Me.Dir1.Size = New System.Drawing.Size(144, 144)
        Me.Dir1.TabIndex = 2
        '
        'Label1
        '
        Me.Label1.BackColor = System.Drawing.SystemColors.Control
        Me.Label1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Label1.ForeColor = System.Drawing.SystemColors.ControlText
        Me.Label1.Location = New System.Drawing.Point(10, 9)
        Me.Label1.Name = "Label1"
        Me.Label1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Label1.Size = New System.Drawing.Size(70, 20)
        Me.Label1.TabIndex = 11
        Me.Label1.Text = "文件名:"
        '
        'Drive1
        '
        Me.Drive1.BackColor = System.Drawing.SystemColors.Window
        Me.Drive1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Drive1.DropDownWidth = 186
        Me.Drive1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Drive1.Location = New System.Drawing.Point(8, 144)
        Me.Drive1.Name = "Drive1"
        Me.Drive1.Size = New System.Drawing.Size(144, 22)
        Me.Drive1.TabIndex = 0
        '
        'Command1
        '
        Me.Command1.BackColor = System.Drawing.SystemColors.Control
        Me.Command1.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command1.Location = New System.Drawing.Point(8, 48)
        Me.Command1.Name = "Command1"
        Me.Command1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command1.Size = New System.Drawing.Size(94, 29)
        Me.Command1.TabIndex = 4
        Me.Command1.Text = "播放(&P)"
        '
        'File1
        '
        Me.File1.BackColor = System.Drawing.SystemColors.Window
        Me.File1.Cursor = System.Windows.Forms.Cursors.Default
        Me.File1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.File1.Location = New System.Drawing.Point(160, 144)
        Me.File1.Name = "File1"
        Me.File1.Pattern = "*.mp3"
        Me.File1.Size = New System.Drawing.Size(200, 172)
        Me.File1.TabIndex = 1
        '
        'Command2
        '
        Me.Command2.BackColor = System.Drawing.SystemColors.Control
        Me.Command2.Cursor = System.Windows.Forms.Cursors.Default
        Me.Command2.Location = New System.Drawing.Point(8, 96)
        Me.Command2.Name = "Command2"
        Me.Command2.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Command2.Size = New System.Drawing.Size(94, 29)
        Me.Command2.TabIndex = 5
        Me.Command2.Text = "停止(&S)"
        '
        'ActiveMovie1
        '
        Me.ActiveMovie1.Location = New System.Drawing.Point(240, 288)
        Me.ActiveMovie1.Name = "ActiveMovie1"
        Me.ActiveMovie1.OcxState = CType(resources.GetObject("ActiveMovie1.OcxState"), System.Windows.Forms.AxHost.State)
        Me.ActiveMovie1.Size = New System.Drawing.Size(286, 225)
        Me.ActiveMovie1.TabIndex = 10
        Me.ActiveMovie1.Visible = False
        '
        'Text1
        '
        Me.Text1.AcceptsReturn = True
        Me.Text1.AutoSize = False
        Me.Text1.BackColor = System.Drawing.SystemColors.Window
        Me.Text1.Cursor = System.Windows.Forms.Cursors.IBeam
        Me.Text1.ForeColor = System.Drawing.SystemColors.WindowText
        Me.Text1.Location = New System.Drawing.Point(61, 9)
        Me.Text1.MaxLength = 0
        Me.Text1.Name = "Text1"
        Me.Text1.RightToLeft = System.Windows.Forms.RightToLeft.No
        Me.Text1.Size = New System.Drawing.Size(299, 21)
        Me.Text1.TabIndex = 3
        Me.Text1.Text = ""
        '
        'mp3test
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(576, 503)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Command2, Me.Command1, Me.Text1, Me.Dir1, Me.File1, Me.Drive1, Me.ActiveMovie1, Me.Label1})
        Me.Location = New System.Drawing.Point(75, 100)
        Me.Name = "mp3test"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.Manual
        Me.Text = "MP3 音乐播放范例"
        CType(Me.ActiveMovie1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub
#End Region 
#Region "升级支持"
	Private Shared m_vb6FormDefInstance As mp3test
	Private Shared m_InitializingDefInstance As Boolean
	Public Shared Property DefInstance() As mp3test
		Get
			If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
				m_InitializingDefInstance = True
				m_vb6FormDefInstance = New mp3test()
				m_InitializingDefInstance = False
			End If
			DefInstance = m_vb6FormDefInstance
		End Get
		Set
			m_vb6FormDefInstance = Value
		End Set
	End Property
#End Region 
	Private Sub Command1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command1.Click

        ActiveMovie1.FileName = Text1.Text

        ActiveMovie1.AutoStart = True
    End Sub

    Private Sub Command2_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Command2.Click
        ActiveMovie1.Stop()
    End Sub

    Private Sub Command5_Click()
        ActiveMovie1.Visible = False
    End Sub

    Private Sub Dir1_Change(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Dir1.Change
        File1.Path = Dir1.Path
    End Sub

    Private Sub Drive1_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Drive1.SelectedIndexChanged
        Dir1.Path = Drive1.Drive
    End Sub

    Private Sub File1_SelectedIndexChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles File1.SelectedIndexChanged
        Dim FileName As Object

        If VB.Right(Dir1.Path, 1) = "\" Then

            FileName = Dir1.Path & File1.FileName
        Else

            FileName = Dir1.Path & "\" & File1.FileName
        End If

        Text1.Text = FileName
    End Sub

    Private Sub mp3test_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

⌨️ 快捷键说明

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