previous next

Chapter 2: Using VBScript and the ActiveX Control

You can use VBScript with the RealPlayer G2 ActiveX control to provide playback capabilities within these products:

Using RealPlayer Methods through VBScript

To extend RealPlayer's ActiveX functionality on Internet Explorer, you first embed the source file in an HTML page with the <OBJECT> tag:


<OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH=220 HEIGHT=180>
<PARAM NAME="SRC" VALUE="rtsp://realserver.company.com/media/animate.swf">
<PARAM NAME="CONSOLE" VALUE="one">
<PARAM NAME="CONTROLS" VALUE="ImageWindow">
<PARAM NAME="BACKGROUNDCOLOR" VALUE="white">
<PARAM NAME="CENTER" VALUE="true">
</OBJECT>

In the <OBJECT> tag, the ID parameter identifies the embedded clip for reference by VBScript parameters.

You can then use VBScript to issue RealPlayer commands to control the embedded presentation. The following example shows a simple form that provides a Play, Pause, and Stop button for the embedded presentation. Click here to see this presentation.


<FORM>
<input TYPE="button" VALUE="Play" NAME="doplay">
<script LANGUAGE="VBScript" FOR="doplay" EVENT="onClick">
RVOCX.DoPlay
</script>
<input TYPE="button" VALUE="Pause" NAME="pause">
<script LANGUAGE="VBScript" FOR="pause" EVENT="onClick">
RVOCX.DoPause
</script>
<input TYPE="button" VALUE="Stop" NAME="stop">
<script LANGUAGE="VBScript" FOR="stop" EVENT="onClick">
RVOCX.DoStop
</script>
</FORM>

Additional Information
The section "Methods" lists the RealPlayer methods.

Handling URLs through <OBJECT>

You can use the AUTOGOTOURL parameter in the <OBJECT> tag to determine how URLs in the presentation are handled. The default value of true applies if you leave the parameter out. In this case any URL embedded in the presentation goes to the browser. If you set this parameter to false, RealPlayer sends the URL to the application with the OnGotoURL() call.

Note
The SetAutoGoToURL() method can override the AUTOGOTOURL parameter.

Using PREFETCH with <OBJECT>

The PREFETCH parameter causes RealPlayer G2 to get the stream description information before the stream starts. You can use this to find out the size and width of an embedded clip, for example, then dynamically create the <OBJECT> tag for the image window, using the clip's native size for the WIDTH and HEIGHT parameters. To do this, you would embed a control, such as the default control panel, and set PREFETCH to true:


<OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH=400 HEIGHT=100>
<PARAM NAME="SRC" VALUE="rtsp://realserver.company.com/media/animate.swf">
<PARAM NAME="CONSOLE" VALUE="one">
<PARAM NAME="CONTROLS" VALUE="All">
<PARAM NAME="PREFETCH" VALUE="true">
</OBJECT>

The control fetches the stream information, then responds with the callback OnPreFetchComplete(). You next use GetClipWidth() and GetClipHeight() to determine the native size of the image window. Through a means such as DHTML, you can then create the image window control. If the width and height were 320 by 240, respectively, you could generate an <OBJECT> tag like the following:


<OBJECT ID=RVOCX CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" WIDTH=320 HEIGHT=240>
<PARAM NAME="SRC" VALUE="rtsp://realserver.company.com/media/animate.swf">
<PARAM NAME="CONSOLE" VALUE="one">
<PARAM NAME="CONTROLS" VALUE="ImageWindow">
</OBJECT>

Receiving Callbacks

To receive callbacks through VBScript, you use the <OBJECT> tag ID, shown here set to RVOCX:


<OBJECT ID=RVOCX HEIGHT=256 WIDTH=256>
CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"
<PARAM NAME="controls" VALUE="all">
<PARAM NAME="SRC" VALUE="http://www.company.com/sample.ram">
</OBJECT>

You then use a <SCRIPT> tag to receive a VBScript callback. The following example shows a callback for onShowStatus(statusText):


<P>
Status Text:
<input type="text" name="statusText" size=100><br>
</P>
<SCRIPT language="VBS">
Sub RVOCX_OnShowStatus(byVal text)
statusText.Value=text
End Sub
</SCRIPT>

Additional Information
The section "CallBack Methods" lists the RealPlayer callback events.


Copyright © 1998 RealNetworks
For information on RealNetworks' technical support, click here.
Comments on this document? Click here.
This file last updated on 12/18/98 at 17:51:29.
previous next