Windows Media Player Control SDK Banner Art
*Contents *Index  *Topic Contents
*Previous Topic: Placing the Windows Media Player Control in a Web Page
*Next Topic: Architecture

Placing the Windows Media Player Control in a Visual Basic Application

Microsoft® ActiveX® technology is an ideal way to add multimedia content to a Web page. Under certain circumstances, however, a stand-alone application may be more appropriate. This section describes the basic steps used to create a simple application with Microsoft® Visual Basic® 5.0 and the Microsoft® Windows Media™ Player control. This section assumes the reader has some knowledge of Visual Basic and the Visual Basic 5.0 development environment.

Note: Stand-alone applications do not support DVD-Video playback.

This article contains the following sections.

Installing the Windows Media Player Control

If the Windows Media Player control is properly installed on your system, the Visual Basic development environment provides an easy procedure for installing the control in your project's toolbox. The Windows Media Player control is listed as Microsoft Windows Media Player on the Controls tab of the Components dialog box.

This example assumes that your project is a standard executable with one form.

Inserting the Windows Media Player Control

First add the Windows Media Player control to the form. Change the FileName property to the name of a multimedia file on your computer (for example, C:\ASFRoot\Welcome.asf).

Change the AutoStart property to False and the AutoRewind property to True. You will add a custom user interface to the form, so change the ShowControls property to False.

Set the ClipControls property to False. By default, Visual Basic sets this property to True. When the Windows Media Player control is embedded in a Visual Basic form, however, this property must be False to avoid problems in repainting.

Adding Button Controls

Next add three CommandButton controls to your form, below the Windows Media Player control object. Change the caption on the first button to Start, on the second to Stop, and on the third to About. Add the following event procedures to the form's code view, so that Visual Basic will recognize when the buttons are clicked.

Private Sub Command1_Click()
    MediaPlayer1.Play
End Sub

Private Sub Command2_Click()
    MediaPlayer1.Stop
End Sub

Private Sub Command3_Click()
    MediaPlayer1.AboutBox
End Sub

Now, you can play and stop a multimedia file by clicking the Start and Stop buttons, respectively. After clicking the About button, a message box appears containing copyright and version information for the Windows Media Player control.

Compiling and Running

Start your application and check the results. If you specified a valid multimedia file in the FileName property, clicking the Play button should start the presentation. Clicking the Stop button stops the presentation. The About button displays a dialog box containing the version number of the Windows Media Player control.


Top of Page Top of Page
© 1999 Microsoft and/or its suppliers. All rights reserved. Terms of Use.