Windows Media Player control : Media Player « Windows « VB.Net Tutorial

VB.Net Tutorial
1. Language Basics
2. Data Type
3. Operator
4. Statements
5. Date Time
6. Class Module
7. Development
8. Collections
9. Generics
10. Attributes
11. Event
12. Stream File
13. GUI
14. GUI Applications
15. 2D Graphics
16. I18N Internationlization
17. Reflection
18. Regular Expressions
19. Security
20. Socket Network
21. Thread
22. Windows
23. XML
24. Database ADO.net
25. Design Patterns
Microsoft Office Word 2007 Tutorial
Java
Java Tutorial
Java Source Code / Java Documentation
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
C# / C Sharp
C# / CSharp Tutorial
ASP.Net
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
PHP
Python
SQL Server / T-SQL
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial » Windows » Media Player 
22. 27. 1. Windows Media Player control
 


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

   ' action menus
   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

   ' media player control
   Friend WithEvents player As AxMediaPlayer.AxMediaPlayer
   Friend WithEvents openMediaFileDialog As OpenFileDialog

#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 NothingThen
            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.
   <System.Diagnostics.DebuggerStepThrough()Private Sub InitializeComponent()
      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()
      '
      'applicationMenu
      '
      Me.applicationMenu.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.fileItem, Me.aboutItem})
      '
      'fileItem
      '
      Me.fileItem.Index = 0
      Me.fileItem.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.openItem, Me.exitItem})
      Me.fileItem.Text = "File"
      '
      'openItem
      '
      Me.openItem.Index = 0
      Me.openItem.Text = "Open"
      '
      'exitItem
      '
      Me.exitItem.Index = 1
      Me.exitItem.Text = "Exit"
      '
      'aboutItem
      '
      Me.aboutItem.Index = 1
      Me.aboutItem.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.aboutMessageItem})
      Me.aboutItem.Text = "About"
      '
      'aboutMessageItem
      '
      Me.aboutMessageItem.Index = 0
      Me.aboutMessageItem.Text = "About Windows Media Player"
      '
      '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(312288)
      Me.player.TabIndex = 0
      '
      'FrmMediaPlayer
      '
      Me.AutoScaleBaseSize = New System.Drawing.Size(513)
      Me.ClientSize = New System.Drawing.Size(312287)
      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.EventArgsHandles 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 ' openItem_Click

   ' exit application
   Private Sub exitItem_Click(ByVal sender As System.Object, _
      ByVal e As System.EventArgsHandles exitItem.Click

      Application.Exit()
   End Sub ' exitItem_Click

   Private Sub aboutMessageItem_Click(ByVal sender As _
      System.Object, ByVal e As System.EventArgs_
      Handles aboutMessageItem.Click

      player.AboutBox()
   End Sub 

End Class

        
22. 27. Media Player
22. 27. 1. Windows Media Player control
w_w__w_.__j_a__v_a__2_s___.__c___o__m_ | Contact Us
Copyright 2003 - 08 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.