Chapter: Internet & World Wide Web HOW TO PROGRAM - Multimedia: Audio, Video, Speech Synthesis and Recognition

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail

RealPlayer Plug-in

A RealPlayer object may be embedded into a Web page to enhance the page with streaming audio and video.

RealPlayer™ Plug-in

 

A RealPlayer object may be embedded into a Web page to enhance the page with streaming audio and video. RealPlayer can also be delivered as a browser plug-in on multiple plat forms. Figure 33.14 demonstrates streaming audio in a Web page by embedding a Real-Player object in the page using embed element. Users can select from several different audio sources; this selection then calls a JavaScript which invokes RealPlayer methods to play the selected audio stream.

 

            <?xml version = "1.0"?>

            <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

           

            <!-- Fig. 33.14: real.html         -->

            <!-- Embedding RealPlayer into an XHTML page -->

                       

            <html xmlns = "http://www.w3.org/1999/xhtml">

            <head>

            <title>Live Audio!</title>

           

            <script type = "text/javascript">

            <!--

            var locations =

            [ "http://www.cnn.com/video/audio/cnn.ram",

            "http://www.real.com/showcase/kingredir.ram",

            "http://radio.onlinemusic.com/play/" +

            "jazzsummit.com/rm" ]

           

            function change( loc )

            {

            raControl.SetSource( locations[ loc ] );

            raControl.DoPlayPause();

            }

            // -->

            </script>

            </head>

           

            <body>

           

            <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>

            </select></p>

 

            <br />

            <embed id = "raControl" src = ""

            type = "audio/x-pn-realaudio-plugin" width = "275"

            height = "125" controls = "Default"

            autostart = "false" />

           

            </body>

            </html>


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

www.real.com/devzone/library/stream/plugtest/plugin.html

 

We do not set the src attribute of the embed element. Normally, this is the location of the streaming audio, but in this example, we use JavaScript to change the source dynamically based on user selections.

 

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:

 

www.cnn.com

www.msnbc.com 

www.broadcast.com/television

 

To learn more about programming with RealPlayer, visit the RealPlayer DevZone at

 

www.realnetworks.com/devzone/index.html

 

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.

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.