Embed RealPlayer in Web pages

Source: Internet
Author: User

Inserts the RealPlayer ActiveX object (if you want to test, you need to install the RealPlayer player first)

Assume that the following code is included in the video.php document (the file will be linked through <iframe> in the main page). <object width= "320"
height= "classid=" "CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" >

<param name= "CONTROLS" value= "Imagewindow" >

<param name= "CONSOLE" value= "video" >

<param name= "CENTER" value= "TRUE" >

<param name= "Maintainspect" value= "TRUE" >

</object>//definition of the playback interface

<object width= "height=" classid= "CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" >

<param name= "CONTROLS" value= "StatusBar" >

<param name= "CONSOLE" value= "video" >

</object>//define status bar

<object width= "height=" classid= "CLSID:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA" >

<param name= "CONTROLS" value= "ControlPanel" >

<param name= "CONSOLE" value= "video" >

<param name= "SRC" value= "<?php Echo getsrc ();?>" >

<param name= "AUTOSTART" value= "TRUE" >

<param name= "PREFETCH" value= "0" >

<param name= "LOOP" value= "0" >

<param name= "Numloop" value= "0" >

</object>//define Control Panel

Where the controls parameter is used to specify the appearance of the control for the player, it can be combined with multiple controls and associated with the console parameter.

For Param parameters, readers can refer to the RealPlayer official website http://service.real.com/help/library/guides/production/htmfiles/control.htm.

The SRC parameter is particularly important here to specify the URL address of the video stream file. Here the author uses the method of PHP code to specify SRC dynamically, the reader can also use other such as ASP, or completely through
JavaScript implementation.


Ii. using DHTML to dynamically control playback of RealPlayer controls

The magical:<iframe> of small tricks. Because the new SRC needs to be refreshed for the RealPlayer control, you can embed the RealPlayer control in a separate page using <IFRAME>, so that dynamic refresh is done in <IFRAME>. Does not affect the user viewing other content on the page.

The following code is included in the main page:

<iframe id= "Ivideo" src= "video.php" width=500
height=345 frameborder=0 scrolling= "No" >

</iframe>, where the video.php file displays the RealPlayer control forcefully.


Here we add a simple JavaScript code to control the playback of the video.

<script language= "JavaScript" >

function Play (filename) {

Top.document.all ("Ivideo"). src = "video.php?src=" +filename;

}//Ivideo is the identifier of the IFRAME just defined

</script>

We can use JavaScript to control the more complex features of the RealPlayer plug-in, such as extracting the length of the video, testing the user's network rate, customizing playback events, and so on. About RealPlayer
For specific details of ActiveX development, please refer to the RealPlayer official website http://service.real.com/help/library/guides/extend/embed.htm.

Let's say we have a video file with a URL of http://YourURL/filename.ram, so we can define it like this:

<a href= "Javascript:play (' Http://YourURL/filename.ram ')" > file 1</a> If the file is local, the URL can also be a relative path.


Third, detect whether the user installs RealPlayer player

Add the following JavaScript code to the

<script language=javascript>

<!--

var realmode=0;

var realplayer5=0;

var realplayer4=0;

var realplayerg2=0;


if (Navigator.userAgent.indexOf ("MSIE") < 0) {

Numplugins = Navigator.plugins.length;

for (i = 0; i < numplugins; i++) {

plugin = Navigator.plugins[i];

if (plugin.name.substring (0,10) = = "RealPlayer") {

realmode=1;

}

}

}

The following code creates a RealPlayer object dynamically through the CreateObject () function of VBScript

document.write (' <script language=vbscript/>/n ');

document.write (' On Error Resume next/n ');

document.write (' RealPlayerG2 = (not IsNull (CreateObject) (Rmocx. RealPlayer
G2 control "))/n ');

document.write (' RealPlayer5 = (not IsNull (CreateObject ("Realplayer.realplayer (tm)
ActiveX control (32-bit)))/n ');

document.write (' RealPlayer4 = (not IsNull (CreateObject ("Realvideo.realvideo (tm)
ActiveX control (32-bit)))/n ');

document.write (' </SCRIPT/>/n ');

if (RealPlayerG2 | | RealPlayer5 | | REALPLAYER4) {

You can add <object> objects here

}else if (realmode) {//Netscape browser user

<embed> objects can be added here

}else{

Window.location.replace ("install.htm"); Transfer to Install.htm page to instruct users to install

}

-->

</Script>


At this point, we have implemented a web-based video on-demand basic functions.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.