Why is this not a video?
-------------------------------------------------- -------------
First, insert 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 (this file will be linked via
Object> / / Define Play Interface
Object> // Define Status Bar
Object> // Define Control Panel
Among them, the Controls parameter is used to specify the appearance of the control of the player, and can be combined with multiple controls and associated with the console parameter.
For Param parameters, readers can refer to RealPlayer official website http://service.real.com/help/library/guides/Production/htmfiles/Control.htm.
The SRC parameters here are particularly important, used to specify the URL address of the video stream file. Here, the author uses the PHP code to dynamically specify the SRC, and the reader can also use other as ASPs, or fully through the JavaScript.
Second, use DHTML dynamic control of the playback of the RealPlayer control
Tips:
The following code is included in the main page:
Iframe>, where the video.php file is used to display the RealPlayer control.
Below we join simple JavaScript code to control video playback.
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 feature of the RealPlayer plugin, such as extracting video's long width, testing users' network rate, custom play events, etc. For specific details about RealPlayer ActiveX, see RealPlayer Official Website http://service.real.com/help/emrary/guides/extend/embed.htm.
We assume that there is a video file, its URL is http: //yoururl/filename.ram, then we can define this:
File 1 If the file is in local, the URL can also be a relative path.
Third, detect whether the user is installed a RealPlayer player
Add the following JavaScript code to the
head> section of the page to detect if the user installs the RealPlayer player:
VAR realMode = 0;
Var RealPlayer5 = 0; var realplayer4 = 0;
Var RealPlayerg2 = 0;
IF (Navigator.UserageRagent.indexof ("MSIE") <0) {
Numplugins = navigator.plugins.LENGTH;
For (i = 0; i Plugin = navigator.plugins [i]; IF (plugin.name.substring (0, 10) == "realplayer") { Realmode = 1; } } } // The following code creates a RealPlayer object through the CreateObject () function of VBScript. Document.write (' / n'); Document.write ('On Error ResMe next / n'); Document.write ('RealPlayerg2 = (CreateObject ("RMocx.RealPlayer G2 Control") / n'); Document.write ('RealPlayer5 = (CreateObject ("RealPlayer.RealPlayer (TM) ActiveX Control (32-bit))) / n') Document.write ('RealPlayer4 = (CreateObject ("Realvideo.RealVideo (TM) ActiveX Control (32-bit)))) / n') Document.write (' script /> / n'); IF (RealPlayerg2 | | RealPlayer5 | | RealPlayer4) { / / You can add } else if (realmode) {// Netscape browser user / / Can add } else { Window.Location.Replace ("install.htm"); // Transfer to install.htm page Guide users to install } -> Script> At this point, we have implemented a basic function of web-based video on demand. But we must want to make more perfect, but also other more complex considerations. If the streaming media is produced, the design of the web is designed, the network flow rate is considered, and the effective organization of the website video file. These topics have exceeded the discussion scope of this article, please refer to the relevant information.