previous next

Chapter 5: Javascript Commands

Using Javascript commands, you can enhance RealPlayer presentations. This chapter describes commands that you can use to play a clip in the media playback pane, set the media playback pane's background color, and open an HTML page in the related info or media browser pane. Although these methods are simple, a familiarity with Javascript is recommended.

Note: The methods described in this chapter are intended only for HTML pages that display in the related info and media browser panes, not for HTML pages rendered by another Web browser.

Tip: For samples of the PlayClip() method in action, download the zipped HTML version of this guide as described in "How to Download This Guide to Your Computer", copy the entire samples folder to your C: drive, and view the HTML page in the interactive folder.

For More Information: For instructions about using all of the Javascript and VBScript methods available for RealPlayer, see RealPlayer Scripting Guide.

Declaring Javascript Methods

To use the methods described in this chapter, you must declare them in the script section of the HTML page displayed in the media browser pane or the related info pane. Here is an example:

<SCRIPT LANGUAGE="JavaScript">
<!--
function RealOneLink(URL,clipinfo,context_URL,width,height){
window.parent.external.PlayClip(URL,clipinfo,context_URL,width,height)
}
function BrowserLink(URL){
window.parent.external.OpenURLInPlayerBrowser(URL)
}
function BackgroundColor(color){
window.parent.external.SetVideoBackgroundColor(color)
}
-->
</SCRIPT>

Playing a Clip

The PlayClip() method allows you to create a hypertext link that opens a clip in the media playback pane. Optionally, it can pass clip information, open HTML pages in the related info and media browser panes, and set the size of the related info pane. A Ram file can perform all of these actions, too, but using a Ram file displays a file download dialog when RealPlayer requests the file. Using the Javascript PlayClip() method prevents this dialog.

PlayClip() Arguments

The PlayClip() method uses the following arguments. Only the URL argument is required to specify a clip to play in the media playback pane.

URL

The URL argument provides the fully-qualified URL to the media clip. For testing, you can use an absolute, local URL (such as file:///C:/temp/clip.rm), but not a relative, local URL.

clipinfo

This argument contains a string of clip information that the viewer can display by choosing the File>Clip Properties>View Clip Info command, or pressing Ctrl+i. It takes the same values as the Ram file clipinfo parameter, which is described in "Setting Clip Information". Separate the subvalues with vertical lines, or "pipes," as shown here:

`title=My Presentation|artist name=Pat Morales|...'

context_url

This argument gives the fully-qualified URL to the HTML page to display in the related info pane as soon as the clip starts to play.

width and height

These two arguments set the width and height of the related info pane in pixels. For more on related info pane sizing, see "Related Info Pane Sizing".

media_browser_url

This argument gives the fully-qualified URL to the HTML page to display in the media browser pane as soon as the clip starts to play.

Opening a Page in the Media Browser Pane

You can use the OpenURLInPlayerBrowser() method in the related info pane to open an HTML page in the media browser pane. This method uses only a URL argument, which provides the fully-qualified URL to an HTML page. For testing, you can use an absolute, local URL (such as file:///C:/temp/page1.html), but not a relative, local URL.

Setting the Media Background Color

The SetVideoBackgroundColor() method sets a color that displays behind the clip playing in the media playback pane. This background color appears if you set the related info pane to a height greater than the playing clip. Black is the default background color. The method takes a color value as an argument. You can specify colors in an RGB format, as in rgb(120,40,87), or as hexadecimal values, as in #AF543C.


RealNetworks, Inc. ©2002, 2004 RealNetworks, Inc. All rights reserved.
For more information, visit RealNetworks
Click here if the Table of Contents frame is not visible at the left side of your screen.
previous next