Using the Windows Media Player Control with Microsoft Visual Studio • • 3 minutes to read In this article You can add the Windows Media Player 9 Series or later ActiveX control to a.NET Framework application through the Toolbox in Visual Studio. Adding the Windows Media Player Control Before creating a new project, make sure that the latest version of Windows Media Player and the Windows Media Player SDK is installed on your computer.
Start Visual Studio, then create a new project. In Visual Studio, open the Toolbox. If Windows Media Player does not appear in the Components portion of the Toolbox, do the following: • Right-click within the Toolbox, and then select Choose Items. This opens the Customize Toolbox dialog box. • On the COM Components tab, select Windows Media Player. If Windows Media Player does not appear in the list, click Browse, and then open Wmp.dll, which should be in the Windows System32 folder.
The Windows Media Player SDK provides features that affect the behavior of Windows Media Player and Windows Media Player for Windows Mobile. The following sections detail SDK features that apply to Windows Media Player in general. Registry Settings Details values that you can change in the user's.
The Windows Media Player control will be placed on the current Toolbox tab. You can now select Windows Media Player in the Toolbox and add it to a form. Visual Studio gives the Windows Media Player control a default name such as 'axWindowsMediaPlayer1'. You may want to change the name to something more easily remembered, such as 'Player'.
Adding the Windows Media Player control from the Toolbox also adds references to two libraries created by Visual Studio, AxWMPLib and WMPLib. You can find them in the Solution Explorer under References. To make using the objects in the Player namespace easier, you should include the namespace in the using or imports directives of your files, as follows: // [C#] using WMPLib; ' [Visual Basic] imports WMPLib The directive ensures that you can refer to Player objects without fully qualifying their names. Note The Windows Media Player control is an AxWindowsMediaPlayer object from the AxWMPLib namespace. However, the AxWindowsMediaPlayer class uses data types, interfaces, and other elements from the WMPLib namespace. Configuring Visibility of the Control When you first add the Windows Media Player control to a form, it will be visible. If you do not want to use the visible image of the Player in your application, hide the default Player by setting any one of the following properties: Property Value uiMode 'invisible' (See.) Visible 'false' Size.Width 0 Size.Height 0 You can set these properties either in code or in the Properties window when the Windows Media Player control is selected in the form designer.