Using the Player Control in a Visual Basic Application

ActiveX technology is an ideal way to add multimedia to a Web page. However, under certain circumstances a standalone application may be more appropriate. This section describes the basic steps used to create a simple application by using Visual Basic version 5.0 and the Player control. This section assumes the reader has some knowledge of Visual Basic and the Visual Basic version 5.0 development environment.

Getting Started

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

This simple sample assumes that your project is a standard executable with one form. Try the following steps to create your own Visual Basic Player application.

Inserting the Player Control

Add the player control to the form. Change the FileName property to a multimedia file on your computer (for example C:\ASFRoot\Welcome.asf). Change the AutoStart property to False, and the AutoRewind property to True. Because we are adding our own simple user interface to the form, change the ShowControls property to False.

Adding Button Controls

Add three CommandButton controls to your form below the Player control object. Change the caption on the first button to Start, the second button to Stop, and the third button to About. Then add the following code to the form:

Private Sub Command1_Click()
    MediaPlayer1.Play
End Sub
Private Sub Command2_Click()
    MediaPlayer1.Stop
End Sub
Private Sub Command3_Click()
    MediaPlayer1.AboutBox
End Sub

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 should stop the presentation.

The About button displays a dialog box containing the version number of the Player control.

© 1996-1998 Microsoft Corporation. All rights reserved.