在flash中用javascript控制页面中的mediaplay
做了一个FLASH按钮来控制mediaplay。 以下是网页部分代码 <BR><BR>function VolDn() <BR>{ // 增音 <BR>var ps = Player.settings; <BR>if(ps.mute == true){ps.mute = false;return;} <BR>else{ <BR>if (ps.volume <= 30){ ps.volume =0;} <BR>else{ps.volume = ps.volume - 30;} <BR><BR>} <BR><BR>} <BR><BR>function VolUp() <BR>{ //减音 <BR>var ps = Player.settings; <BR>if(ps.mute == true){ps.mute = false;return;} <BR>else{ <BR>if (ps.volume >= (100-30)) {ps.volume = 100;} <BR>else { ps.volume = ps.volume + 30;} <BR><BR>} <BR><BR>} <BR>function playerPlay(){ <BR>Player.URL="mms://202.95.107.151/pggame"> <BR>} <BR><BR>function playerStop(){ <BR><BR>if(Player.status!="准备就绪") <BR>Player.controls.stop(); <BR>else return; <BR>} <STRONG>mediaplay 代码</STRONG> <BR><BR><BR><OBJECT ID=Player CLASSID="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6"type="application/x-oleobject" Standby="Loading.... Microsoft Windows Media Player" <BR>width="0" height="0" style="position:absolute;left:0px; top:0px;"> <BR><PARAM NAME="URL" value="mms://202.95.107.151/pggame"> <BR><PARAM NAME="rate" value="1"> <BR><PARAM NAME="balance" value="0"> <BR><PARAM NAME="currentPosition" value="0"> <BR><PARAM NAME="defaultFrame" value=""> <BR><PARAM NAME="playCount" value="1"> <BR><PARAM NAME="autoStart" value="1"> <BR><PARAM NAME="currentMarker" value="0"> <BR><PARAM NAME="invokeURLs" value="-1"> <BR><PARAM NAME="baseURL" value=""> <BR><PARAM NAME="volume" value="100"> <BR><PARAM NAME="mute" value="0"> <BR><PARAM NAME="uiMode" value="full"> <BR><PARAM NAME="stretchToFit" value="0"> <BR><PARAM NAME="windowlessVideo" value="0"> <BR><PARAM NAME="enabled" value="-1"> <BR><PARAM NAME="enableContextMenu" value="0"> <BR><PARAM NAME="fullScreen" value="0"> <BR><PARAM NAME="SAMIStyle" value=""> <BR><PARAM NAME="SAMILang" value=""> <BR><PARAM NAME="SAMIFilename" value=""> <BR><PARAM NAME="captioningID" value=""> <BR></OBJECT> ------------------- <BR>以上代码 用HTML按钮控制都无问题。 flash用简单的命令控制。 <BR>如 <BR>b1.onRelease=function(){ <BR>getURL("javascript :VolUp()"); <BR>} <BR>bt2.onRelease=function(){ <BR>getURL("javascript :VolDn()"); <BR>b3.onRelease=function(){ <BR>getURL("javascript :playerPlay()"); <BR>} <BR>bt4.onRelease=function(){ <BR>getURL("javascript :playerStop()"); ------------- <BR>播放和停止都能用,但一用增音和减音,播放器就会停止。百思不得其解, 烦有空高手给解决一下,高分送上。 怎么现实增声减音。 <BR>--------------------------------------------------------------- <BR>使用fscommand传递命令,不要用javascript。 即在Flash中, <BR>b1.onRelease=function(){ <BR>fscommand("VolUp"); <BR>} <BR>在HTML中,在你现有的Javascript基础上添加 <BR>var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1; <BR>// 处理 Flash 影片中的所有 FSCommand 消息 <BR>function FlashControl_DoFSCommand(command, args) { <BR>var FlashControl = isInternetExplorer ? document.all.FlashControl : document.FlashControl; <BR>// 代码放在此处。 <BR>eval(command)(); <BR>} <BR>// Internet Explorer 的挂钩 <BR>if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) { <BR>document.write(’’<script language=\"VBscript\"\>\n’’); <BR>document.write(’’On Error Resume Next\n’’); <BR>document.write(’’Sub FlashControl_FSCommand(ByVal command, ByVal args)\n’’); <BR>document.write(’’ Call FlashControl_DoFSCommand(command, args)\n’’); <BR>document.write(’’End Sub\n’’); <BR>document.write(’’</script\>\n’’); <BR>} 以上FlashControl为嵌入HTML中的Flash Object id <BR>--------------------------------------------------------------- <BR><BR> 简单看了看,帮你修改了一下。VBscript的问题。帮你把Javascript中的一段代码拿出来,就好使了。 <BR><BR>Javascript中的这个代码提出去 <BR>// Internet Explorer 的挂钩 <BR>if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) { <BR>document.write(’’<script language=\"VBscript\"\>\n’’); <BR>document.write(’’On Error Resume Next\n’’); <BR>document.write(’’Sub FlashControl_FSCommand(ByVal command, ByVal args)\n’’); <BR>document.write(’’ Call FlashControl_DoFSCommand(command, args)\n’’); <BR>document.write(’’End Sub\n’’); <BR>document.write(’’</script\>\n’’); <BR>} <BR><BR>为 <BR><script language="VBscript"> <BR>On Error Resume Next <BR>Sub FlashControl_FSCommand(ByVal command, ByVal args) <BR>Call FlashControl_DoFSCommand(command, args) <BR>End Sub <BR></script> <BR>就好用了,试试吧 <BR><BR>页:
[1]