by Chirantan Bhattacharjee (6 Submissions)
Category: Sound/MP3
Compatability: VB.NET
Difficulty: Unknown Difficulty
Originally Published: Sat 4th November 2006
Date Added: Mon 8th February 2021
Rating: (1 Votes)
creates your own media player.
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
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
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents AxWindowsMediaPlayer1 As AxWMPLib.AxWindowsMediaPlayer
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem2 As System.Windows.Forms.MenuItem
Friend WithEvents ListBox1 As System.Windows.Forms.ListBox
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents NotifyIcon1 As System.Windows.Forms.NotifyIcon
Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
Friend WithEvents MenuItem5 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem6 As System.Windows.Forms.MenuItem
Friend WithEvents StatusBar1 As System.Windows.Forms.StatusBar
Friend WithEvents StatusBarPanel1 As System.Windows.Forms.StatusBarPanel
Friend WithEvents StatusBarPanel2 As System.Windows.Forms.StatusBarPanel
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents MenuItem4 As System.Windows.Forms.MenuItem
Friend WithEvents MenuItem12 As System.Windows.Forms.MenuItem
Friend WithEvents AxAnimation1 As AxMSComCtl2.AxAnimation
Friend WithEvents AxBalloonTipDemo1 As AxBalloonTipOCXDemo.AxBalloonTipDemo
Friend WithEvents statusbarpanel3 As System.Windows.Forms.StatusBarPanel
Friend WithEvents MenuItem8 As System.Windows.Forms.MenuItem
Friend WithEvents StatusBarPanel4 As System.Windows.Forms.StatusBarPanel
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.AxWindowsMediaPlayer1 = New AxWMPLib.AxWindowsMediaPlayer()
Me.MainMenu1 = New System.Windows.Forms.MainMenu()
Me.MenuItem1 = New System.Windows.Forms.MenuItem()
Me.MenuItem2 = New System.Windows.Forms.MenuItem()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.NotifyIcon1 = New System.Windows.Forms.NotifyIcon(Me.components)
Me.ContextMenu1 = New System.Windows.Forms.ContextMenu()
Me.MenuItem5 = New System.Windows.Forms.MenuItem()
Me.MenuItem6 = New System.Windows.Forms.MenuItem()
Me.MenuItem8 = New System.Windows.Forms.MenuItem()
Me.MenuItem4 = New System.Windows.Forms.MenuItem()
Me.MenuItem12 = New System.Windows.Forms.MenuItem()
Me.StatusBar1 = New System.Windows.Forms.StatusBar()
Me.StatusBarPanel1 = New System.Windows.Forms.StatusBarPanel()
Me.StatusBarPanel2 = New System.Windows.Forms.StatusBarPanel()
Me.statusbarpanel3 = New System.Windows.Forms.StatusBarPanel()
Me.StatusBarPanel4 = New System.Windows.Forms.StatusBarPanel()
Me.Label2 = New System.Windows.Forms.Label()
Me.AxAnimation1 = New AxMSComCtl2.AxAnimation()
Me.AxBalloonTipDemo1 = New AxBalloonTipOCXDemo.AxBalloonTipDemo()
CType(Me.AxWindowsMediaPlayer1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.statusbarpanel3, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.StatusBarPanel4, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.AxAnimation1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.AxBalloonTipDemo1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'AxWindowsMediaPlayer1
'
Me.AxWindowsMediaPlayer1.AccessibleRole = System.Windows.Forms.AccessibleRole.None
Me.AxWindowsMediaPlayer1.AllowDrop = True
'Me.AxWindowsMediaPlayer1.enabled = True
Me.AxWindowsMediaPlayer1.ImeMode = System.Windows.Forms.ImeMode.On
Me.AxWindowsMediaPlayer1.Location = New System.Drawing.Point(24, 16)
Me.AxWindowsMediaPlayer1.Name = "AxWindowsMediaPlayer1"
Me.AxWindowsMediaPlayer1.OcxState = CType(resources.GetObject("AxWindowsMediaPlayer1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxWindowsMediaPlayer1.Size = New System.Drawing.Size(600, 472)
Me.AxWindowsMediaPlayer1.TabIndex = 0
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1})
'
'MenuItem1
'
Me.MenuItem1.Index = 0
Me.MenuItem1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem2})
Me.MenuItem1.Text = "&FILE"
'
'MenuItem2
'
Me.MenuItem2.Index = 0
Me.MenuItem2.Shortcut = System.Windows.Forms.Shortcut.CtrlO
Me.MenuItem2.Text = "OPEN"
'
'ListBox1
'
Me.ListBox1.BackColor = System.Drawing.Color.Black
Me.ListBox1.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle
Me.ListBox1.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.ListBox1.ForeColor = System.Drawing.Color.Gray
Me.ListBox1.HorizontalScrollbar = True
Me.ListBox1.ItemHeight = 16
Me.ListBox1.Location = New System.Drawing.Point(636, 40)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(144, 418)
Me.ListBox1.TabIndex = 2
'
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.BackColor = System.Drawing.SystemColors.ActiveBorder
Me.Label1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D
Me.Label1.FlatStyle = System.Windows.Forms.FlatStyle.Flat
Me.Label1.Font = New System.Drawing.Font("Tahoma", 9.75!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.Label1.ForeColor = System.Drawing.Color.Black
Me.Label1.Location = New System.Drawing.Point(664, 8)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(72, 18)
Me.Label1.TabIndex = 5
Me.Label1.Text = "PLAYLIST"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft
'
'NotifyIcon1
'
Me.NotifyIcon1.ContextMenu = Me.ContextMenu1
Me.NotifyIcon1.Icon = CType(resources.GetObject("NotifyIcon1.Icon"), System.Drawing.Icon)
Me.NotifyIcon1.Text = "AV Player"
Me.NotifyIcon1.Visible = True
'
'ContextMenu1
'
Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem5, Me.MenuItem6, Me.MenuItem8, Me.MenuItem4, Me.MenuItem12})
'
'MenuItem5
'
Me.MenuItem5.Enabled = False
Me.MenuItem5.Index = 0
Me.MenuItem5.Shortcut = System.Windows.Forms.Shortcut.CtrlF
Me.MenuItem5.ShowShortcut = False
Me.MenuItem5.Text = "FULL SCREEN"
'
'MenuItem6
'
Me.MenuItem6.Index = 1
Me.MenuItem6.Text = "-"
'
'MenuItem8
'
Me.MenuItem8.Checked = True
Me.MenuItem8.Index = 2
Me.MenuItem8.Text = "100%"
'
'MenuItem4
'
Me.MenuItem4.Index = 3
Me.MenuItem4.Text = "200%"
'
'MenuItem12
'
Me.MenuItem12.Index = 4
Me.MenuItem12.Text = "-"
'
'StatusBar1
'
Me.StatusBar1.Location = New System.Drawing.Point(0, 515)
Me.StatusBar1.Name = "StatusBar1"
Me.StatusBar1.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.StatusBarPanel1, Me.StatusBarPanel2, Me.statusbarpanel3, Me.StatusBarPanel4})
Me.StatusBar1.ShowPanels = True
Me.StatusBar1.Size = New System.Drawing.Size(802, 16)
Me.StatusBar1.TabIndex = 6
'
'StatusBarPanel1
'
Me.StatusBarPanel1.Width = 225
'
'StatusBarPanel2
'
Me.StatusBarPanel2.Width = 250
'
'statusbarpanel3
'
Me.statusbarpanel3.Width = 200
'
'StatusBarPanel4
'
Me.StatusBarPanel4.Width = 200
'
'Label2
'
Me.Label2.BackColor = System.Drawing.Color.Black
Me.Label2.Location = New System.Drawing.Point(24, 424)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(600, 16)
Me.Label2.TabIndex = 9
Me.Label2.Text = "Label2"
'
'AxAnimation1
'
Me.AxAnimation1.Location = New System.Drawing.Point(664, 464)
Me.AxAnimation1.Name = "AxAnimation1"
Me.AxAnimation1.OcxState = CType(resources.GetObject("AxAnimation1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxAnimation1.Size = New System.Drawing.Size(96, 48)
Me.AxAnimation1.TabIndex = 11
'
'AxBalloonTipDemo1
'
Me.AxBalloonTipDemo1.Enabled = True
Me.AxBalloonTipDemo1.Location = New System.Drawing.Point(8, 120)
Me.AxBalloonTipDemo1.Name = "AxBalloonTipDemo1"
Me.AxBalloonTipDemo1.OcxState = CType(resources.GetObject("AxBalloonTipDemo1.OcxState"), System.Windows.Forms.AxHost.State)
Me.AxBalloonTipDemo1.Size = New System.Drawing.Size(37, 33)
Me.AxBalloonTipDemo1.TabIndex = 12
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.BackColor = System.Drawing.SystemColors.ActiveBorder
Me.ClientSize = New System.Drawing.Size(802, 531)
Me.ContextMenu = Me.ContextMenu1
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.AxBalloonTipDemo1, Me.AxAnimation1, Me.Label2, Me.StatusBar1, Me.Label1, Me.ListBox1, Me.AxWindowsMediaPlayer1})
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.KeyPreview = True
Me.Menu = Me.MainMenu1
Me.Name = "Form1"
Me.Text = "Audio & Video Player"
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
CType(Me.AxWindowsMediaPlayer1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.StatusBarPanel1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.StatusBarPanel2, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.statusbarpanel3, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.StatusBarPanel4, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.AxAnimation1, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.AxBalloonTipDemo1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub MenuItem2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem2.Click
Dim ARR() As String
Dim opn As New OpenFileDialog()
Dim I As Integer
'opn.AddExtension = True
opn.Multiselect = True
opn.Filter = ("Media Files(*.dat)|*.dat|Avi Files|*.avi|Mpeg Files|*.mpeg|Mpg Files|*.mpg|Mp3 Files|*.mp3")
opn.ShowDialog()
ListBox1.Items.AddRange(opn.FileNames)
Me.ListBox1.SelectedIndex = 0
Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
'Me.AxWindowsMediaPlayer1.newPlaylist = Me.ListBox1.Items
'Me.AxWindowsMediaPlayer1.URL = opn.FileName
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
Me.AxWindowsMediaPlayer1.fullScreen = False
'Me.AxWindowsMediaPlayer1.ImeMode = False
'Me.AxWindowsMediaPlayer1.ContextMenu = ContextMenu1
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.DoubleClick
Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
'MsgBox(Me.ListBox1.SelectedItem)
End Sub
Private Sub AxWindowsMediaPlayer1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxWindowsMediaPlayer1.Enter
'Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
End Sub
'Private Sub AxWindowsMediaPlayer1_playstatechange(ByVal sender As System.Object, ByVal e As System.Windows.Forms.NavigateEventHandler) Handles AxWindowsMediaPlayer1.PlayStateChange
' Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
'End Sub
Private Sub TrackBar1_Scroll(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Me.AxWindowsMediaPlayer1.playState.wmppsScanForward(WMPLib.WMPSliderCtrl)
End Sub
Private Sub MenuItem5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem5.Click
If Me.AxWindowsMediaPlayer1.playState = WMPLib.WMPPlayState.wmppsPlaying Then
Me.AxWindowsMediaPlayer1.fullScreen = True
End If
End Sub
Private Sub MenuItem6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem6.Click
'Me.AxWindowsMediaPlayer1.uiMode = 50%
End Sub
Private Sub ListBox1_SelectedIndexChanged_1(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles ListBox1.KeyDown
'MsgBox(e.KeyCode)
If e.KeyCode = 46 Then
ElseIf e.KeyCode = 13 Then
Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
End If
End Sub
Private Sub AxWindowsMediaPlayer1_PLAYSTATE(ByVal sender As System.Object, ByVal e As AxWMPLib._WMPOCXEvents_PlayStateChangeEvent) Handles AxWindowsMediaPlayer1.PlayStateChange
Dim i As Integer
On Error Resume Next
'MsgBox(e.newState)
If e.newState = 1 Then
Me.AxAnimation1.AutoPlay = False
Me.AxAnimation1.Close()
MenuItem5.Enabled = False
ElseIf e.newState = 2 Then
Me.AxAnimation1.AutoPlay = False
MenuItem5.Enabled = False
ElseIf e.newState = 3 Then
Me.AxAnimation1.AutoPlay = True
Me.AxAnimation1.Open("D:\Documents and Settings\Administrator\My Documents\MONTY (PERSONAL)\wmplayer\dillo.avi")
MenuItem5.Enabled = True
ElseIf e.newState = 9 Then
Me.AxAnimation1.AutoPlay = False
MenuItem5.Enabled = False
ElseIf e.newState = 8 Then
Me.AxAnimation1.AutoPlay = False
MenuItem5.Enabled = False
Me.ListBox1.SelectedIndex += 1
Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
'Me.AxWindowsMediaPlayer1.newMedia(Me.ListBox1.SelectedItem)
'Me.AxWindowsMediaPlayer1.launchURL(Me.ListBox1.SelectedItem)
'MsgBox(e.newState)
ElseIf e.newState = 7 Then
Me.AxAnimation1.AutoPlay = False
Me.AxAnimation1.Close()
MenuItem5.Enabled = False
Else
MenuItem5.Enabled = False
'Me.AxWindowsMediaPlayer1.URL = Me.ListBox1.SelectedItem
End If
Me.StatusBarPanel2.Text = "Clip : " + Me.AxWindowsMediaPlayer1.currentMedia.name
Me.StatusBarPanel1.Text = "Current Operation : " & Me.AxWindowsMediaPlayer1.status
Me.StatusBarPanel4.Text = "Duration : " & Me.AxWindowsMediaPlayer1.currentMedia.durationString
Me.statusbarpanel3.Text = "Type of File : " & CStr(Mid(Me.ListBox1.SelectedItem, Len(Me.ListBox1.SelectedItem) - 2))
End Sub
Private Sub NotifyIcon1_Mousemove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles NotifyIcon1.MouseMove
Me.AxBalloonTipDemo1.ShowTip()
If Me.StatusBarPanel1.Text = "" Then
Me.AxBalloonTipDemo1.TitleText = "AVPlayer"
Me.AxBalloonTipDemo1.TipText = "Open File"
Else
Me.AxBalloonTipDemo1.TitleText = Me.AxWindowsMediaPlayer1.currentMedia.name
Me.AxBalloonTipDemo1.TipText = Me.StatusBarPanel1.Text
End If
End Sub
Private Sub MenuItem8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem8.Click
Me.AxWindowsMediaPlayer1.stretchToFit = False
Me.MenuItem8.Checked = True
Me.MenuItem4.Checked = False
End Sub
Private Sub MenuItem4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem4.Click
Me.AxWindowsMediaPlayer1.stretchToFit = True
Me.MenuItem4.Checked = True
Me.MenuItem8.Checked = False
End Sub
End Class
'make sure all the controls are taken in the form.
'Please reply how you like our service
'Please reply to [email protected]