<?xml version = "1.0"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<!-- Fig. 33.14: real.html -->
<!-- Embedding RealPlayer into an XHTML page -->
<html xmlns = "http://www.w3.org/1999/xhtml">
var locations =
function change( loc )
raControl.SetSource( locations[ loc ] );
<p>Pick from my favorite audio streams:
<select id = "streamSelect" onchange =
"change( this.value )">
<option value = "">Select a station</option>
<option value = "0">CNN</option>
<option value = "1">KING-FM</option>
<option value = "2">Jazz Summit</option>
<embed id = "raControl" src = ""
type = "audio/x-pn-realaudio-plugin" width = "275"
height = "125" controls = "Default"
autostart = "false" />
Fig. 33.14 Embedding RealPlayer in a Web page
The embed element in lines 42–45 embeds the RealPlayer plug-in into the page. The type attribute specifies the MIME type of the embedded file, which in this case is the MIME type for streaming audio. (Remember that MIME is a standard for specifying the format of content so the browser can determine how to handle the content.) The width and height attributes specify the dimensions of the space the control occupies on the page. The autostart attribute determines whether the audio starts playing when the page loads (for this example, we set it to false). The controls attribute specifies which controls users can access (e.g., Play button, Pause button and Volume Control). Setting controls to Default places the standard control buttons on screen. A list of the avail-able controls can be found at the site
Now that the player is embedded in the Web page, we use scripting to activate the streaming audio. The select menu (line 33) lists three radio stations, corresponding to the three entries in the array locations (defined at line 14), which contain the actual URLs for the live audio of those stations. When the selection changes, function change (line 20) is called by the onchange event. This function calls methods SetSource and DoPlayPause of the RealPlayer object. Method SetSource sets the source URL of the audio stream to be played. Then, method DoPlayPause toggles between pausing and playing the stream. [Note: In this case, the stream is paused because it has not started playing yet, so it begins playing in response to the call to DoPlayPause.]
In this example, we only explore streaming audio. The latest versions of RealPlayer support streaming video as well. To view streaming video with RealPlayer, visit the fol-lowing sites:
To learn more about programming with RealPlayer, visit the RealPlayer DevZone at
A few years, ago broadcasting personal streaming audio and video required a dedicated server and expensive software. Today, open source software, such as Darwin Streaming Server and RealNetwork’s Basic Server G2, provide “home-made” servers, such as Linux or Apache running on a PC, with streaming capability. These applications are available free for download from www.shareware.com. With limited server processor power and Internet bandwidth, this type of set-up cannot support the same number of streams and bit-rates as a dedicated streaming server.
Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.