Chinaunix首页 | 论坛 | 博客
  • 博客访问: 3287687
  • 博文数量: 266
  • 博客积分: 3081
  • 博客等级: 中校
  • 技术积分: 2640
  • 用 户 组: 普通用户
  • 注册时间: 2005-07-04 10:35
个人简介

没什么好介绍的!穷屌丝一个~

文章分类

全部博文(266)

文章存档

2021年(3)

2020年(1)

2019年(2)

2016年(5)

2015年(1)

2014年(1)

2011年(9)

2010年(16)

2009年(31)

2008年(58)

2007年(111)

2006年(2)

2005年(26)

我的朋友

分类:

2008-03-16 23:33:47

Chapter 8: Playing a Presentation in a Web Page

Embedding a presentation in your Web page provides seamless playback without launching RealPlayer as a separate application. You can even include RealPlayer controls such as fast forward and pause. This chapter explains how you add mark-up to your Web page so that people view your RealSystem G2 presentation directly through their Web browsers.

Additional Information
Refer to this chapter for full information on embedding a presentation. For a quick example of how to embed a video in a Web page, see .

Choosing the Netscape Plug-in or ActiveX Control

To provide Web page playback, RealPlayer includes a plug-in for browsers that support the Netscape plug-in architecture:

  • Netscape Navigator 3.0, 4.0, and higher.

  • Microsoft Internet Explorer 3.0 and 4.0.

It also has an ActiveX control that provides playback capabilities within these products:

  • Microsoft Internet Explorer 3.0 and 4.0.

  • Any application that supports ActiveX controls, such as Visual Basic, Visual C++, Microsoft Access, and so on.

Because they both have the same capabilities, you can use either the plug-in or the ActiveX control depending on which products you need to support. The following sections describe the basics of using the plug-in or the control, then explain each parameter you can set.

Note
Familiarity with RealPlayer and HTML will make it easier to use the plug-in or control. In the examples below, ellipses (...) indicate information left out to keep the examples short. Make sure your tags include all necessary information.

Additional Information
Embedded RealPlayer Extended Functionality Guide at explains how to use JavaScript or VBScript to extend the functionality of the Netscape Plug-in or ActiveX control.

Using Tags for the Netscape Plug-In

To use RealPlayer's Netscape plug-in, you add tags to your Web page HTML. Each tag has three required parameters (SRC, WIDTH, HEIGHT), and can include many optional parameters. The basic tag looks like the following (the SRC value, which is explained below, has been omitted for simplicity):


This tag creates a playback area 300 pixels wide by 134 pixels high within the Web page. Parameters typically have the form PARAMETER=value. The parameter names can be any case, though this manual shows them uppercase. Except for file names, which must typically be lowercase, parameter values are not case-sensitive. Unless they are URLs, parameter values do not need to be inside quotation marks.

Supporting Other Browsers

To accommodate browsers that do not support the Netscape plug-in, use </FONT></CODE> to define a standard hypertext link to your presentation. The unembedded link follows the <CODE><FONT face=新宋体><EMBED></FONT></CODE> tag:</P><PRE> <EMBED SRC="..." WIDTH=300 HEIGHT=134><BR><NOEMBED><A HREF="...">Play with RealPlayer.</A>

In this example, browsers that can play the embedded presentation hide the text between </FONT></CODE> and <CODE><FONT face=新宋体>. Other browsers ignore the preceding tag and display just the hypertext link. The user then clicks the link to play the presentation in RealPlayer.

Using Tags for the ActiveX Control

You embed the RealPlayer ActiveX control in HTML pages with the tag. This tag uses an ID that you select, such as ID=RVOCX, and must have the following class ID that identifies RealPlayer:

CLASSID="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"

The tag also sets the width and height of the playback area within the browser. A typical tag looks like this:

WIDTH=300 HEIGHT=134>
... parameters ...

This tag creates a playback area 300 pixels wide by 134 pixels high within the Web page. Between and , you can define any number of additional parameters in this form:


PARAM, NAME, and VALUE markers can be any case, though this manual shows them uppercase. Parameter values are not case-sensitive except for file names, which must typically be lowercase. Always enclose parameter values in double quotation marks.

Setting Basic Parameters

Both the Netscape plug-in and ActiveX control use the same basic tag parameters. As explained above, the tag syntax for the plug-in and the control differs, however. The following sections explain the basic parameters you can include in each or tag.

SRC

The SRC parameter gives the presentation's source URL surrounded by double quotes. The directory names cannot contain spaces. For the ActiveX control, the tag's CLASSID parameter causes the presentation to play back in the Web page, so you can simply link to the SMIL file or clip within one tag. When linking to a presentation on RealServer, the URL can use Ramgen, but this is not necessary:


When you use the Netscape plug-in, you need to include the SRC parameter in every tag. You can specify two types of URLs. The first uses the ?embed option to RealServer's Ramgen, which causes RealPlayer to play the clip or SMIL presentation through its Netscape plug-in instead of launching as a separate application:

SRC="?embed"

Additional Information
For more on Ramgen and presentation URLs, see .

The second option is to create a Ram file with a .rpm extension and list this file in the SRC parameter without including Ramgen and the ?embed option. The Ram file then links to your SMIL file or clips. The following example links to a .rpm file on a Web server:

SRC=""

Additional Information
For instructions on writing a .rpm file, see .

You must create and link to a .rpm file in any of the following situations:

  • Your RealServer does not use Ramgen.

  • The SMIL file or clip is on a Web server.

  • All files are located on a user's local computer rather than streamed over a network.

    Note
    When linking to local files, you can use relative links or absolute links. When you use absolute links with the Netscape plug-in, though, use forward slashes in paths. For example, instead of file://c:\media\first.rpm, set the source as file://c:/media/first.rpm.

WIDTH and HEIGHT

Required for each or tag, the WIDTH and HEIGHT parameters set the size of the playback area. If you leave them out, the playback area may appear as a tiny icon because streaming media presentations do not size automatically. The values for WIDTH and HEIGHT are in pixels by default, so a width of 300 creates a playback area 300 pixels wide. Setting WIDTH and HEIGHT to 0 (zero) hides the playback area.

You can also express WIDTH and HEIGHT as percentages of the browser window size. For example, a width of 50% makes the presentation area half the browser width. Keep in mind that different types of media scale with different results. A video scaled larger than its encoded size may not look good. Vector-based media such as Flash with RealSystem G2 animation scale more easily to fit different playback areas, however.

NOJAVA

Setting NOJAVA to true in every tag prevents the browser's Java Virtual Machine (JVM) from starting if it is not yet running:


This is recommended when using the Netscape plug-in because the JVM is not required for the parameters described in this chapter. Starting the JVM therefore delays presentation playback unnecessarily. The JVM is required only when extending plug-in functionality with JavaScript. In this case, omit NOJAVA entirely from the tags.

Additional Information
See Embedded RealPlayer Extended Functionality Guide at for more information on controlling RealPlayer with JavaScript.

Note
Although you can include NOJAVA as an ActiveX parameter, it has no effect on Internet Explorer, which launches its JVM on browser start-up.

Adding RealPlayer Controls

With the CONTROLS parameter, you can place RealPlayer controls such as a play/pause button in your Web page. A visitor to your page can then control the presentation playback just as if using RealPlayer as a separate application. The following example for the Netscape tag displays the play/pause button:

CONTROLS=PlayButton>

For the ActiveX control, you define a CONTROLS parameter within the tag structure:




The following sections describe each RealPlayer control you can use. A tag's WIDTH and HEIGHT parameters set the control's size. The suggested pixel widths and heights given below produce embedded controls approximately the same sizes as the RealPlayer controls. Specifying different pixel sizes scales the controls larger or smaller. You can also use percentage values for sizes, but this is recommended only for the image window.

Additional Information
For information on adding more than one control to your Web page, see .

Tip
If you have installed RealPlayer G2, to see a Web page with all the embedded controls.

Basic Controls

ImageWindow

Displays the image window. This is available only for display presentations such as video or animation. Even if no other controls are visible on the page, the user can typically right-click (on Windows) or hold down the mouse button (Macintosh) on the playback area to display a menu of choices such as Play and Stop. See also .

Suggested pixel width: 176 or higher
Suggested pixel height: 132 or higher

All

Displays the basic RealPlayer control panel. The control name "default" also works. Buttons include play, pause, stop, fast forward, and rewind. Sliders include a position slider and a volume slider with mute button that pops up when the speaker button is clicked. Below the buttons are a clip information field, a status panel, a network congestion indicator, and a clip timing field.

Suggested pixel width: 375
Suggested pixel height: 100

Individual Controls and Sliders

ControlPanel

Displays the play, pause, stop, fast forward and rewind buttons. There's also a position slider, along with a volume slider and mute button that pops up when the speaker button is clicked.

Suggested pixel width: 350
Suggested pixel height: 36

PlayButton

Displays a play/pause button.

Suggested pixel width: 44
Suggested pixel height: 26

PlayOnlyButton

Displays a play button.

Suggested pixel width: 26
Suggested pixel height: 26

PauseButton

Displays a pause button.

Suggested pixel width: 26
Suggested pixel height: 26

StopButton

Displays a stop button.

Suggested pixel width: 26
Suggested pixel height: 26

FFCtrl

Displays a fast forward control.

Suggested pixel width: 26
Suggested pixel height: 26

RWCtrl

Displays a rewind control.

Suggested pixel width: 26
Suggested pixel height: 26

MuteCtrl

Displays a mute button.

Suggested pixel width: 26
Suggested pixel height: 26

MuteVolume

Displays a mute button and volume slider.

Suggested pixel width: 26
Suggested pixel height: 88

VolumeSlider

Displays a volume slider.

Suggested pixel width: 26
Suggested pixel height: 65

PositionSlider

Displays a clip position slider.

Suggested pixel width: 120
Suggested pixel height: 26

TACCtrl

Displays a clip information field. For instructions on formatting the clip playlist, see .

Suggested pixel width: 370
Suggested pixel height: 32

HomeCtrl

Displays the Real™ logo.

Suggested pixel width: 45
Suggested pixel height: 25

Information Panels

InfoVolumePanel

Displays presentation information along with the volume slider and mute button. For more on presentation information, see . See also .

Suggested pixel width: 325
Suggested pixel height: 55

InfoPanel

Displays the presentation information panel. For more on presentation information, see . See also .

Suggested pixel width: 300
Suggested pixel height: 55

Status Panels

StatusBar

Displays the status panel, which shows informational messages. It also includes the network congestion LED and the position field, which shows current place in the presentation timeline along with total clip length.

Suggested pixel width: 300
Suggested pixel height: 30

Note
The status bar is included in the All control. If you do not embed a status bar or status field in your page, error messages display in the browser's status bar.

StatusField

Displays the message text area of the status bar. If you do not embed a status field or status bar in your page, error messages display in the browser's status bar.

Suggested pixel width: 200
Suggested pixel height: 30

PositionField

Displays the position field, which shows the clip's current place in the presentation timeline and the total clip length.

Suggested pixel width: 90
Suggested pixel height: 30

Linking Multiple Controls

The CONSOLE parameter defines a name that unifies or tags so that multiple controls work together. For example, you could create three separate or tags to define an image window, a play button, and a stop button. By using three tags, you can set the size of each control separately and define its layout with HTML tags. You could put each control in a different HTML table cell, for example.

To tie controls together, define the same CONSOLE name within each or tag, or use one of these predefined names:

_master links the control to all other embedded controls on the page.

_unique links the control to no other embedded controls on the page.

You can have multiple console names for separate presentations. For a page showing two video clips, for example, you can define console names of video1 and video2. All controls linked by video1 interoperate and all controls linked by video2 interoperate. But a video1 volume slider, for example, will not affect the volume of a video2 clip.

Tips for Using Consoles

Note the following when grouping multiple controls with CONSOLE attributes:

  • Every tag must have a SRC attribute. Tags linked by a console name should have the same SRC value.

  • With the ActiveX control, only one tag in a console group needs to have a SRC value.

  • If the or tags in a console group have different SRC values, the first valid source that RealPlayer finds among those choices becomes the console source. This may not always be the first source listed.

  • Clicking a play button for one console stops playback for other consoles. This allows multiple consoles to play separate audio tracks or to use the same image window.
  • Multiple Controls Example

    The following examples for the and tags set up an image window and two sets of controls (a play button and stop button) for separate videos, sample1.rm and sample2.rm. The predefined console name _master links the image window to both control sets. The control sets use different console names, however, so they do not link to each other. Clicking each play button therefore starts a different video.

    Netscape Plug-in Sample Mark-up

    Because each tag must have a SRC value, the image window in the following example simply uses the same source as the first play button. The viewer simply clicks either play button to start a video. Clicking the other play button stops the first video and plays the second video.

    WIDTH=176 HEIGHT=128 NOJAVA=true CONTROLS=ImageWindow CONSOLE=_master>
    

    Video 1


    WIDTH=44 HEIGHT=26 NOJAVA=true CONTROLS=PlayButton CONSOLE=video1>
    WIDTH=26 HEIGHT=26 NOJAVA=true CONTROLS=StopButton CONSOLE=video1>

    Video 2


    WIDTH=44 HEIGHT=26 NOJAVA=true CONTROLS=PlayButton CONSOLE=video2>
    WIDTH=26 HEIGHT=26 NOJAVA=true CONTROLS=StopButton CONSOLE=video2>

    ActiveX Control Sample Mark-up

    In the following ActiveX example, only the controls for the two play buttons define the source URLs. For convenience the CLASSID value is omitted.




    Video 1










    Video 2










    Controlling Image Display

    The following and parameters control aspects of how clips play back.

    BACKGROUNDCOLOR

    This parameter specifies a background color for the image window. The specified background color also shows through if a clip includes transparency. The background color is black by default. You can use an RGB hexadecimal color value (#RRGGBB) or the following color names, shown here with their corresponding RGB values:

    white (#FFFFFF) silver (#C0C0C0) gray (#808080) black (#000000)
    yellow (#FFFF00) fuchsia (#FF00FF) red (#FF0000) maroon (#800000)
    lime (#00FF00) olive (#808000) green (#008000) purple (#800080)
    aqua (#00FFFF) teal (#008080) blue (#0000FF) navy (#000080)

    Note
    SMIL region background colors override this background color. For more on setting SMIL region colors, see .

    CENTER

    The default value for CENTER is false, which causes the clip to fill the entire playback area. If you set CENTER to true, the clip is centered within the playback area and displays at its encoded size. So by setting CENTER to true, you can create a large playback area with WIDTH and HEIGHT and still have the clip play at its normal size. You cannot use CENTER along with MAINTAINASPECT.

    MAINTAINASPECT

    This parameter, which you cannot combine with CENTER, determines whether the clip's height-to-width ratio stays constant when the clip scales to fit the image window. The default value of false causes this ratio to change as necessary to fill the image window fully. This may distort the source image.

    If you set MAINTAINASPECT to true, a clip's height-to-width ratio stays constant. For example, a clip's height-to-width ratio of 1:1 stays constant even if the image window's height-to-width ratio is 2:3. In these cases, the clip is centered in the image window and scaled until one dimension reaches the window's boundaries and the other dimension is within the boundaries. The following figure shows how clips scale by default, with MAINTAINASPECT set to true, and with CENTER set to true.

    Clip Scaling with MAINTAINASPECT and CENTER

    NOLABELS

    When you use a control that includes presentation information such as title, author, and copyright, you can include the NOLABELS option to suppress that information. Here is an example for the Netscape plug-in:

    NOLABELS=true>
    

    and an example for the ActiveX control:




    NOLOGO

    When set to true, NOLOGO prevents the Real logo from displaying in the image window. When no clip is playing, only the specified background color shows in the window. The parameter is false by default.

    Setting Automatic Playback

    The AUTOSTART, LOOP, and NUMLOOP parameters let you set the content to start playing automatically, as well as loop continuously for a specified number of times. The following example shows two of these parameters used with the Netscape plug-in:

    AUTOSTART=true LOOP=true>
    

    Here is an example for the ActiveX control:





    AUTOSTART

    When set to true, the AUTOSTART parameter starts playback immediately. When you have multiple or tags linked by a CONSOLE name, set AUTOSTART to true in just one tag. Leaving AUTOSTART out or setting its value to false means the presentation does not start until the user starts it, for example, by clicking an embedded play button.

    LOOP

    If the LOOP parameter is set to true, the presentation continuously loops until the viewer stops it. When you have multiple or tags linked by a CONSOLE name, set looping in just one tag. If you leave the LOOP parameter out, the default value of false applies and the presentation stops after the first playback. The user can play the presentation again by clicking the play button.

    NUMLOOP

    If you specify a NUMLOOP value such as "2", the presentation loops the specified number of times and then stops. If both LOOP and NUMLOOP are used, the LOOP parameter is ignored.

    SHUFFLE

    The SHUFFLE parameter is for use only with Ram or SMIL files that list a single sequence of clips. When set to true, SHUFFLE makes RealPlayer play back the clips in a random order.

    Laying out SMIL Presentations

    As explains, you can use a SMIL file to define separate playback regions for different parts of a presentation. This lets you lay out two clips side-by-side, for example. When playing a presentation in a Web page, you can define the layout in SMIL or in HTML.

    Defining the Layout with SMIL

    To control the layout through SMIL, you set up the regions and their relative placements in the SMIL file. You then use the Netscape plug-in or ActiveX control to create a playback region in the Web page large enough to accommodate all regions. This SMIL file then produces the same layout when played through the Web page or RealPlayer.

    The sample layout shown in defines three regions, creating a total playback area 430 pixels wide by 165 pixels high. To accommodate this in your Web page, you define an image window at least as large as this through the or tag. Here are examples for the Netscape plug-in:

    WIDTH=430 HEIGHT=165 NOJAVA=true CONTROLS=ImageWindow CONSOLE=one>
    

    and ActiveX control:

    WIDTH=430 HEIGHT=165>



    The SRC parameter provides the URL to the SMIL file. You can then use additional or tags linked to the "one" console to provide RealPlayer controls for the presentation.

    Additional Information
    If you have installed RealPlayer G2, to see a demonstration with a SMIL layout embedded in a Web page. to see the same demonstration play in RealPlayer.

    Defining the Layout with HTML

    The second method omits SMIL layout information and defines the layout through HTML. You could place an image window and separate RealPlayer controls in an HTML table, for example. Each or tags then uses a REGION parameter to define a region name. Clip source tags within the SMIL file list which region each clip plays in. For example, the SMIL file shown in lists the following RealText file, set to play in the newsregion region:

    
    

    Within the HTML page, the tag that plays news.rt would look like this:

    WIDTH=250 HEIGHT=144 NOJAVA=true CONTROLS=ImageWindow 
    REGION=newsregion CONSOLE=one>

    The tag would look like this:






    You define similar or tags to create other regions for other clips listed in the SMIL file. The SRC parameter in each tag lists the same SMIL file. You can also use additional or tags linked to the same console to provide RealPlayer controls for the presentation.

    Additional Information
    If you have installed RealPlayer G2, to see a SMIL demonstration embedded in a Web page with an HTML layout.

    Omitting SMIL Layout Information

    When you define the presentation layout through HTML, you must omit the section from the SMIL file header. For example, the SMIL file shown in would not have a section:









    region="newsregion"/>


    Note
    A SMIL file without a layout still works with RealPlayer G2, but RealPlayer automatically creates the layout, and the results may not be what you expect. Always include a SMIL layout when playing a presentation directly in RealPlayer.

    Parameter Reference

    The following table lists the and tag parameters. Parameters compatible with RealPlayer 5.0 are indicated in the "5.0?" column. To have an embedded presentation play back with RealPlayer 5.0 as well as RealPlayer G2, use only 5.0-compatible parameters.

    and Tag Parameters
    Parameter Function 5.0? Values Default
    Sets automatic playback. yes true|false false
    Sets background color. no color name or RGB hex value black
    Centers clip in window. no true|false false
    Links multiple controls. yes name, _master, or _unique (none)
    Adds RealPlayer controls. yes control name All
    Sets window or control height. yes percentage or pixels (none)
    Loops clips indefinitely. no true|false false
    Preserves image aspect ratio. no true|false false
    Prevents JVM start-up. no true|false false
    Suppresses presentation information. yes true|false false
    Suppresses RealLogo. no true|false false
    Loops clip a given number of times. no any number (none)
    Ties clip to SMIL region. no SMIL region (none)
    Randomizes playback. no true|false false
    Specifies source clip. yes URL (none)
    Sets window or control width. yes percentage or pixels (none)


    © 1998
    For information on RealNetworks' technical support, .
    Comments on this document? .
    This file last updated on 12/18/98 at 14:36:36.

     
    我想这些资料够你用了,你可要有耐心呀!
    
    【基本概念】
    
    在进行设计之前,我们先来了解一些相关的基本概念。
    
    1、标签
    
    是Microsoft在IE4.0之后推出的,用来替代标签的对象定义标签(IE仍然支持),通过classid属性定义相应的对象类型。标签是Netscape浏览器支持的对象定义标签。如果开发者需要同时获得IE和NetScape两种浏览器用户的支持,最好使用标签。
    
    2、定义ram文件
    
    ram格式文件同rm文件一样,也是RealPlayer所支持的视频文件压缩格式,所不同的是ram文件可以仅简单的包括视频文件的URL地址。也就是说,ram文件可以为简单的文本格式,每一行定义一个视频文件的URL地址。
    
    笔者在测试时发现,嵌入式RealPlayer在播放视频文件时,一般采用把视频文件整个下载到本地然后进行播放。这对于较大的视频文件来说,速度让人难以忍受。解决这个问题的方法,一是把视频文件简单的分割成大小适中的小文件分段播放(由于 REAL 公司对 RM 格式的实行“封闭管理”,所以 RM 到目前为止还不能像 MPEG 等视频文件一样用视频软件自由的编辑);另外一种就是采用ram文件。RealPlayer简单的下载文本格式的ram文件,然后取出其中的真实地址,然后自动连接到网络进行实时的点对点播放。其缺点是增加了服务器负担。
    
    类似的,Microsoft Media Player采用asx格式来定义asf文件。
    
    3、DHTML
    
    DHTML是Dynamic HTML的缩写,DHTML通过传统的HTML语言,利用CSS(Cascading Style Sheets,即样式表),并依靠JavaScript使一向静止不变的页面得以“动”起来。 Netscape 4.0和IE 4.0/5.0版本支持DHTML,DHTML是一种完全“客户端”技术,直接通过WEB页面实现页面与用户之间的交互性。DHTML的优秀之处在于增强了Web页面的功能,在Web页面直接建立动画、游戏和应用软件等等,提供了浏览站点的全新方式,与Java、Flash等技术不同的是,用DHTML编制的页面不需要插件的支持就能完整的实现。
    
    
    【设计过程】
    
    下面笔者以IE5.0为例,说明一个嵌入式WEB视频点播系统的实现方法,其中用到了部分PHP和JavaScript技术,有疑惑的读者请参考相关资料。
    
    一、插入RealPlayer ActiveX对象(如果要进行测试,需要先安装RealPlayer播放器)
    
    假定以下代码包含在video.php文档中(该文件将在主页面中通过,其中,video.php文件用力显示RealPlayer控件。
    
    
    下面我们加入简单的JavaScript 代码用来控制视频的播放。
    
    
    
    我们可以使用javascript控制RealPlayer插件更复杂的功能,如提取视频的长宽、测试用户的网络速率、自定义播放事件等等。关于RealPlayer ActiveX开发的具体细节,请参阅RealPlayer官方网站。
    
    我们假设有一个视频文件,其URL为,那么我们就可以这样定义:
    
    文件1,如果文件是在本地,URL也可以为相对路径。
    
    
    三、检测用户是否安装RealPlayer播放器
    
    在页面的部分加入以下JavaScript代码,用以检测用户是否安装RealPlayer播放器:
    
    
    
    
    至此,我们已经实现了一个基于Web的视频点播的基本功能。但我们要想把功能做的更完美一些,还需要其它更复杂的考虑。如流媒体的制作、网页美工的设计、网络流速的考虑,以及网站视频文件的有效组织。这些话题已经超出了本文的讨论范围,请读者自行参考相关资料。 
    
    
    
    
    
    阅读(1280) | 评论(0) | 转发(0) |
    给主人留下些什么吧!~~