Programming Implementation of playing the corresponding ppts file while playing the RM file

Source: Internet
Author: User

Application Scenario:
This situation may occur during the preparation of online courseware. You need to play the RM video file while displaying the corresponding PowerPoint file on a video playback webpage, in addition, the pptfile automatically goes through the page as the video is played.

Code principle:
The corresponding programming interface provided by RealPlayer to obtain the playback time. Make the pptfile into multiple images and adjust the displayed image files based on the obtained playback time.

The code snippet is as follows:

<HTML>
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = gb2312">
<Meta http-equiv = "imagetoolbar" content = "no">

<Script language = "jscript">
<--

T_bytes = new array (, 71 );
I _lit = new array ("1.jpg"," 2.jpg", "3.jpg"," 4.jpg", "5.jpg ");
Pagelit = new array ("Welcome to watch the course video file. "," Depending on network conditions, the buffer duration may be relatively long. Please be patient. "," If you cannot play the video, please refer to learning help. ");
Pageurl = new array ("help.htm", "help.htm", "help.htm ");
Pagerm = "RM/heap sorting. rm ";
Pageso = 1;
Title = "Data Structure ";
Playstr = 0;
Function window. onload (){
Playtime ();
Courseevent ();
Player. setvolume (70 );
Li. src = "pimg/heapsort/" + I _short [0];
LW [PageSo-1]. style. color = "# ffffff ";
SetTimeout ("Player. setsource (pagerm); displaydiv ()", 1000 );
Setinterval ("timetd. innertext = writetime (player. getposition () +/" // "+ writetime (player. getlength ()", 300 );
SetTimeout (scantime, 5000 );
}
 
Function document. onclick (){
With (event. srcelement) if (tagname = "A" | tagname = "IMG") blur ();
}
 
Function document. oncontextmenu (){
Return false;
}
 
Function document. onselectstart (){
Return false;
}
 
Function document. onkeydown (){
Return false;
}

Function playtime (){
If (parseint (player. getposition ()/1000) = t_prop [playstr + 1]) {
Li. src = "pimg/heapsort/" + I _short [playstr + 1];
Playstr + = 1;
Chkbutton ();
}
}

Function GOTO (NO ){
Player. dopause ();
Player. setposition (t_lit.length> 1? T_values [No] * 1000:0 );
Li. src = "pimg/heapsort/" + I _short [No];
Playstr = no;
Chkbutton ();
Player. doplay ();
}
 
Function eventplay (e ){
VaR T = "";
If (E = "play "){
T = 0;
Player. doplay ();
}
If (E = "pause "){
T = 1;
Player. dopause ();
}
If (E = "stop "){
T = 2;
Goto (0 );
Player. dostop ();
Backbox. src = backbox. DSRC;
}
T = 0 | T = 1? New Function () {for (I = 0; I <PPS. length; I ++) PPS [I]. src = PPS [I]. isrc, PPS [T]. src = PPS [T]. DSRC}: New Function () {for (I = 0; I <PPS. length; I ++) PPS [I]. src = PPS [I]. SSRC; PPS [0]. src = PPS [0]. isrc}
}
 
VaR eventobject = 0, old_x, new_x;
Function button_down (){
Eventobject = event. srcelement;
Old_x = event. clientx;
Eventobject. setcapture ();
Eventplay ("pause ");
Clearinterval (sinterval );
}
 
Function button_move (){
If (eventobject ){
New_x = event. clientx;
VaR movepels = eventobject. style. pixelleft + New_X-Old_X;
VaR maxbound = Document. All (eventobject. ID + "box"). offsetWidth-EventObject.offsetWidth;
If (eventobject & movepels <= maxbound & movepels> = 0 ){
Eventobject. style. pixelleft = movepels;
Eval (eventobject. ID + "event (" + eventobject. style. pixelleft + "," + maxbound + ")");
Old_x = new_x;
}
}
}
 
Function button_up (){
If (eventobject ){
Eventobject. releasecapture ();
Eventobject = 0;
Courseevent ();
Changeevent ();
Chkbutton ();
}
}
 
Function coursebuttonevent (l, m ){
Player. setposition (math. Round (player. getlength () * L/m ));
}
 
Function volumebuttonevent (l, m ){
Player. setvolume (math. Round (L/MB) * 100 ));
}
 
Function changeevent (){
VaR returnpos = "";
VaR SnO = player. getposition ()/1000;
For (I = t_lit.length; I> 0; I --) if (t_then [I]> SnO) returnpos = I;
Splay (returnpos );
}
 
Function splay (n ){
N = ""? N = I _lit.length: NULL;
Li. src = "pimg/heapsort/" + I _1_[ n-1];
Playstr = n-1;
Eventplay ("play ");
}
 
Function writetime (p ){
VaR secend = P;
VaR minute = parseint (secend/60000). tostring ();
VaR secend = parseint (secend-minute * 60000)/1000). tostring ();
Minute = minute. Length = 1? 0 + minute: minute;
Secend = secend. Length = 1? 0 + secend: secend;
Return minute + ":" + secend;
}
 
Function backbutton (){
Playstr> 0? New Function () {GOTO (PlayStr-1); nextbox. src = nextbox. SSRC}: NULL;
}
 
Function nextbutton (){
If (playstr <T_lit.length-1 ){
Goto (playstr + 1 );
Backbox. src = backbox. SSRC;
}
}
 
Function chkbutton (){
If (playstr = 0) backbox. src = backbox. DSRC, nextbox. src = nextbox. SSRC;
If (playstr = I _lit.length-1) backbox. src = backbox. SSRC, nextbox. src = nextbox. DSRC;
If (playstr <I _lit.length-1 & playstr> 0) backbox. src = backbox. SSRC, nextbox. src = nextbox. SSRC;
}
Function scantime (){
Player. getplaystate () = 3 & player. getposition () = player. getlength () & pageso! = Pageurl. length? Location = pageurl [pageso]: setTimeout (scantime, 50 );
}
Function displaydiv (){
Player. getplaystate () = 3? Loadbr. style. Display = "NONE": setTimeout (displaydiv, 20 );
}
 
Function courseevent (){
Sinterval = setinterval ("coursebutton. style. pixelleft = math. round (coursebuttonbox. offsetWidth-CourseButton.offsetWidth) * player. getposition ()/player. getlength (); playtime () ", 300 );
}

Function movetextdiv (OBJ, Action ){
Function upmove (){
If (textscroll. offsettop <0 ){
Textscroll. style. pixeltop + = 1;
}
OBJ. src = "image/up_d.gif ";
}
Function downmove (){
If (textscroll. offsettop> (textscrollbox. offsetHeight-TextScroll.offsetHeight )){
Textscroll. style. pixeltop-= 1;
}
OBJ. src = "image/down_d.gif ";
}
Scro = setinterval (Action = "up "? Upmove: downmove, 10 );
Function obj. onmouseout (){
Clearinterval (scro );
OBJ. src = action = "up "? "Image/up_o.gif": "image/down_o.gif ";
}
}
-->
</SCRIPT>

 

 

 

<Title> test </title>
</Head>
<Body leftmargin = "0" topmargin = "0" rightmargin = "0" bottommargin = "0" scroll = "no">
<Table border = "0" cellpadding = "0" cellspacing = "0" width = "760">
<Tr>
<Script language = "jscript">
<! --
Function writetd () {var STR = new array (19,235, 15, 1); for (I = 0; I <Str. length; I ++) document. write ("<TD style =/" width: "+ STR [I] +"; Height: 1/"> </TD>")} writetd ();
-->
</SCRIPT>
</Tr>

<Tr>
<TD colspan = "13"> </TD>
<TD colspan = "7"> </TD>
<TD style = "width: 1; Height: 16"> </TD>
</Tr>

<Tr>
<TD rowspan = "10"> </TD>
<TD colspan = "10" align = "center" background = "image/I _13.jpg" style = "width: 237; Height: 17; color: #003399"> </TD>
<TD rowspan = "4" colspan = "2"> </ TD>
<TD Height = "374" rowspan = "7"> </TD>
<TD rowspan = "7" colspan = "5"> </TD>
<TD rowspan = "11"> </TD>
<TD style = "width: 1; Height: 17"> </TD>
</Tr>
<Tr>
<TD colspan = "10" bgcolor = "#000000">
<Object ID = "Player" classid = "CLSID: cfcdaa03-8be4-11cf-b84b-0020afbbccfa" width = 237 Height = 178>
<Param name = "controls" value = "imagewindow">
<Param name = "autostart" value = "-1">
<Param name = "Shuffle" value = "0">
<Param name = "prefetch" value = "0">
<Param name = "nolabels" value = "0">
<Param name = "loop" value = "0">
<Param name = "numloop" value = "0">
<Param name = "center" value = "0">
<Param name = "maintainaspect" value = "0">
<Param name = "backgroundcolor" value = "#000000">
</Object> </TD>
<TD style = "width: 1; Height: 178"> </TD>
</Tr>
<Tr>
<TD colspan = "4" bgcolor = "#333333"> </TD>
<TD colspan = "5" bgcolor = "#333333" style = "color: # ffffff" id = "timetd"> </TD>
<TD style = "width: 1; Height: 16"> </TD>
</Tr>
<Tr>
<TD> </TD>
<TD colspan = "7" background = "image/I _17.jpg" id = "coursebuttonbox"> </TD>
<TD colspan = "2"> </TD>
<TD style = "width: 1; Height: 10"> </TD>
</Tr>
<Tr>
<TD colspan = "12"> </TD>
<TD style = "width: 1; Height: 5"> </TD>
</Tr>
<Tr>
<TD colspan = "2"> </TD>
<TD> </TD>
<TD> </TD>
<TD colspan = "2" background = "image/I _0000jpg" style = "width: 90; Height: 24" id = "volumebuttonbox"> <Div style = "position: absolute; top: expression (volumebuttonbox. offsettop + 3); left: expression (volumebuttonbox. offsetleft + 3); Background: URL (image/vos.gif); width: expression (volumebutton. style. pixelleft + 5); Height: 15 "> </div>
<A id = "volumebutton" style = "position: relative; left: 70; top:-3; width: 10" onmousedown = "button_down ()" onmousemove = "button_move () "onmouseup =" button_up () ">
</A> </TD>
<TD> </TD>
<TD colspan = "4"> </TD>
<TD> </TD>
<TD style = "width: 1; Height: 24"> </TD>
</Tr>
<Tr>
<TD colspan = "9" rowspan = "4" valign = "bottom" align = "center" background = "image/I _24.jpg" style = "color: # ffffff">
<Div style = "width: 220; Height: 130; overflow: hidden" id = "textscrollbox">
<Div style = "position: relative; top: 0" id = "textscroll">
<Br>
<SCRIPT>
For (I = 0; I <pagelit. length; I ++ ){
Document. write ("<Table Style =/" width: 100%/"> <tr> <TD width =/" 10/"valign =/" Top/"> </TD> <a href =/" "+ pageurl [I] +"/"target =/" _ blank/ "id =/" LW/">" + pagelit [I] + "</a> </TD> </tr> </table> ")
}
</SCRIPT>
</Div>
</Div>


</TD>
<TD rowspan = "4" colspan = "3"> </ TD>
<TD style = "width: 1; Height: 124"> </TD>
</Tr>
<Tr>
<TD> </TD>
<TD rowspan = "2"> </TD>
<TD rowspan = "2"> 0? Isrc: DSRC "onmouseout =" src = playstr> 0? SSRC: DSRC "DSRC =" image/back_d.jpg "isrc =" image/back_ I .jpg "SSRC =" image/back_s.jpg "style =" cursor: Hand "> </TD>
<TD rowspan = "2"> </TD>
<TD rowspan = "2"> </TD>
<TD rowspan = "2"> </TD>
<TD style = "width: 1; Height: 7"> </TD>
</Tr>
<Tr>
<TD> </TD>
<TD style = "width: 1; Height: 11"> </TD>
</Tr>
<Tr>
<TD rowspan = "2" colspan = "3"> </ TD>
<TD rowspan = "2"> </TD>
<TD rowspan = "2"> </TD>
<TD rowspan = "2"> </TD>
<TD style = "width: 1; Height: 2"> </TD>
</Tr>
<Tr>
<TD colspan = "13"> </TD>
<TD style = "width: 1; Height: 20"> </TD>
</Tr>
</Table>

<Div id = "loadbr"> <Div style = "position: absolute; top: 0; left: 0; width: 760; Height: 430; Background: black; filter: alpha (opacity = 50) "> </div> <embed src =" image/loading.swf "style =" position: absolute; top: 180; left: 280 "Quality = high wmode = transparent width = 200 Height = 150 type = application/X-Shockwave-flash> </embed> </div>
</Body>
</Html>

Notes:
The general concept of the program is clear and needless to say. The following is a detailed question.
T_duration = new array (, 71) the RM video playback time at the time when the PPT is switched, in seconds.
I _names = new array ("1.jpg"," 2.jpg", "3.jpg"," 4.jpg", "5.jpg") Name of the PPT file after the image is created.
Pagelit = new array () page displays the text of multiple lines of information.
Pageurl = new array () Click the information text and navigate to the webpage file.
Pagerm = "RM/heap sorting. rm" video file location.
<Object ID = "Player" classid = "CLSID: cfcdaa03-8be4-11cf-b84b-0020afbbccfa" width = 237 Height = 178>
<Param name = "controls" value = "imagewindow">
<Param name = "autostart" value = "-1">
<Param name = "Shuffle" value = "0">
<Param name = "prefetch" value = "0">
<Param name = "nolabels" value = "0">
<Param name = "loop" value = "0">
<Param name = "numloop" value = "0">
<Param name = "center" value = "0">
<Param name = "maintainaspect" value = "0">
<Param name = "backgroundcolor" value = "#000000">
</Object>
This is the code for inserting the RealPlayer plug-in into the webpage.
It is worth noting that it is named player. In other code, we can see that player is used in many places, such as player. getposition (), player. setposition (), player. doplay () and so on. These are the corresponding programming interface functions provided by RealPlayer. The function name shows the purpose of the function. Other code is centered around these interface functions.

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.