Using the Player Control


By using a scripting language such as VBScript, it is easy to embed theNetShow Player control in an HTML page. This section explains how to design an HTML page with an embedded Player control and use VBScript routines to manipulate the control.

HTML Shell

Use the following HTML shell for your application to create a Web page:


<HTML>
<HEAD><TITLE>NetShow Player Control Demo</TITLE></HEAD>
<BODY>
</BODY>
</HTML>

Inserting the Player Control

The <OBJECT> tag is used to embed ActiveX objects like the NetShow Player control into an HTML page. Following is an example of using the <OBJECT> tag to insert the Player control.


<OBJECT ID="nsplay1" WIDTH=160 HEIGHT=120
 CLASSID="CLSID:2179C5D3-EBFF-11cf-B6FD-00AA00B4E220"
 CODEBASE="http://www.microsoft.com/netshow/download/en/nsasfinf.cab#Version=2,0,0,888">
</OBJECT>

The following <OBJECT> tag attributes are required:

Using the CODEBASE attribute is strongly recommended. It contains a URL pointing to where the Player control can be found if it is unavailable on a user's system. Besides the address of the player object, the CODEBASE attribute may also optionally specify a version number of the control.

The Player control is available on Microsoft's Web site packaged as a .cab (cabinet) file. The .ocx file containing the control along with the codecs needed to support the control are compressed into the cabinet. An .inf file included in the cabinet specifies the files that need to be downloaded and performs the setup for the control to run.

Adding the Form

Adding a form and a few buttons is the simplest way to demonstrate Player control operation. Add the following form with three buttons, one to start an ASF Player, one to stop, and one to display the current version of the Player control. The FORM tag should be in the BODY of your page:


<FORM>
<INPUT TYPE="BUTTON" NAME="BtnPlay" VALUE="Play">
<INPUT TYPE="BUTTON" NAME="BtnStop" VALUE="Stop">
<INPUT TYPE="BUTTON" NAME="BtnAbout" VALUE="About">
</FORM>

Adding the Scripting Code

For this sample, VBScript is used. First you must notify the browser which scripting language you intend to use, and then include the scripted commands in a comment. Put the SCRIPT tag anywhere in the BODY and embed the comment-surrounded code within the SCRIPT tags. The code will respond to events on the Web pages, such as clicking, and call methods on the NetShow Player control. For this sample Web page, build the sample ASF file from the ASF Editor and place the Sample.asf file in the same directory as the Web page. This sample uses AutoRewind to rewind the file at the end and also uses CurrentPosition to rewind the file when Stop is called.


<SCRIPT LANGUAGE="VBScript">
<!--
Sub BtnAbout_OnClick
     nsplay1.AboutBox()
End Sub

Sub BtnPlay_OnClick
	nsplay1.AutoRewind = True
	nsplay1.FileName = "sample.asf"
	nsplay1.Play
End Sub

Sub BtnStop_OnClick
	nsplay1.Stop
	nsplay1.CurrentPosition = 0
End Sub
-->
</SCRIPT>

Each subroutine is attached to a specific button that was defined in the FORM section. When a click event is triggered by a button being clicked, the code makes a call (or series of calls) to the Player control.

General Notes

For general information about ActiveX controls, see the Microsoft ActiveX SDK.

For more information about using VBScript with ActiveX controls, see the Visual Basic Script home page.

© 1997 Microsoft Corporation. All rights reserved. Terms of Use.