Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
public class UseMediaPlayer
public Shared Sub Main
Application.Run ( New FrmMediaPlayer )
End Sub
End class
Public Class FrmMediaPlayer
Inherits System.Windows.Forms.Form
Friend WithEvents applicationMenu As MainMenu
Friend WithEvents fileItem As MenuItem
Friend WithEvents openItem As MenuItem
Friend WithEvents exitItem As MenuItem
Friend WithEvents aboutItem As MenuItem
Friend WithEvents aboutMessageItem As MenuItem
Friend WithEvents player As AxMediaPlayer.AxMediaPlayer
Friend WithEvents openMediaFileDialog As OpenFileDialog
#Region " Windows Form Designer generated code "
Public Sub New ()
MyBase.New ()
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
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager ( GetType ( FrmMediaPlayer ))
Me.applicationMenu = New System.Windows.Forms.MainMenu ()
Me.fileItem = New System.Windows.Forms.MenuItem ()
Me.openItem = New System.Windows.Forms.MenuItem ()
Me.exitItem = New System.Windows.Forms.MenuItem ()
Me.aboutItem = New System.Windows.Forms.MenuItem ()
Me.aboutMessageItem = New System.Windows.Forms.MenuItem ()
Me.openMediaFileDialog = New System.Windows.Forms.OpenFileDialog ()
Me.player = New AxMediaPlayer.AxMediaPlayer ()
CType ( Me.player, System.ComponentModel.ISupportInitialize ) .BeginInit ()
Me.SuspendLayout ()
Me.applicationMenu.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.fileItem, Me.aboutItem })
Me.fileItem.Index = 0
Me.fileItem.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.openItem, Me.exitItem })
Me.fileItem.Text = "File"
Me.openItem.Index = 0
Me.openItem.Text = "Open"
Me.exitItem.Index = 1
Me.exitItem.Text = "Exit"
Me.aboutItem.Index = 1
Me.aboutItem.MenuItems.AddRange ( New System.Windows.Forms.MenuItem () { Me.aboutMessageItem })
Me.aboutItem.Text = "About"
Me.aboutMessageItem.Index = 0
Me.aboutMessageItem.Text = "About Windows Media Player"
Me.player.Name = "player"
Me.player.OcxState = CType ( resources.GetObject ( "player.OcxState" ) , System.Windows.Forms.AxHost.State )
Me.player.Size = New System.Drawing.Size ( 312 , 288 )
Me.player.TabIndex = 0
Me.AutoScaleBaseSize = New System.Drawing.Size ( 5 , 13 )
Me.ClientSize = New System.Drawing.Size ( 312 , 287 )
Me.Controls.AddRange ( New System.Windows.Forms.Control () { Me.player })
Me.Menu = Me.applicationMenu
Me.Name = "FrmMediaPlayer"
Me.Text = "MediaPlayer"
CType ( Me.player, System.ComponentModel.ISupportInitialize ) .EndInit ()
Me.ResumeLayout ( False )
End Sub
# End Region
Private Sub openItem_Click ( ByVal sender As System.Object, _
ByVal e As System.EventArgs ) Handles openItem.Click
openMediaFileDialog.ShowDialog ()
player.FileName = openMediaFileDialog.FileName
player.Size = New Size ( player.ImageSourceWidth, player.ImageSourceHeight )
Me.Size = New Size ( player.Size.Width + 20 ,player.Size.Height + 60 )
End Sub
Private Sub exitItem_Click ( ByVal sender As System.Object, _
ByVal e As System.EventArgs ) Handles exitItem.Click
Application.Exit ()
End Sub
Private Sub aboutMessageItem_Click ( ByVal sender As _
System.Object, ByVal e As System.EventArgs ) _
Handles aboutMessageItem.Click
player.AboutBox ()
End Sub
End Class
Tidak ada komentar:
Posting Komentar