求助:因为层里面包含flv文件,要关闭的时候,用隐藏层,播放的flv视频在层隐藏时,仍有视频的声音存在,请问如何才能彻底关闭层,也就是在关闭层时同时关闭视频,
希望高手帮帮忙啊! 

解决方案 »

  1.   

    document.getElementById("id").remove(true);
      

  2.   

    建议你还是做隐藏,至于你说的问题还是很好解决的,每种播放器都是可以通过JS来调用它的函数的,比如
    MD就有STOP函数来停止影片的播放。隐藏同时停止播放就OK了,否则你就要卡率小小内存用户在页面停留过长操作过多而引起的内存开销问题了
      

  3.   

    层只是一个载体,你的目的是关闭播放器,所以你应该提问,如何关闭那个播放器才是真的!
    如果把div销毁了,又想打开播放器呢,又得再次创建
      

  4.   

    我的博客有一篇以前找到的MD的详细参数的文章你可以看看,其他播放器的就GOOGLE一下吧,应该都差不多的
      

  5.   

    别的都不利用的话,最简单的,就有一个变通方法:1.另外搞一个小小的FLV,显示一个网站LOGO之类画面就行,或者是点击播放之类的提示画面。2.当你要关闭当前FLV的播放,只要把OBJECT的播放文件名更换成这个FLV就行了。要播放的时候,把文件名再换回去即可。
      

  6.   

    不能修改播放器吗??在播放器中添加一个js回调的函数,提供js调用函数停止播放就行了。如下注意下面为as脚本,as引擎使用的是js的引擎,所以和js差不多function stopPlay(){
      //停止播放器播放的as脚本
    }
    //注册事件提供给外部js调用,具体意义自己查找这个函数
    flash.external.ExternalInterface.addCallback("forJSStop", null, stopPlay);js调用//swfId:为你object,embed对象的id和name
    function stop(){ //js调用flash中注册的方法,
     if(window["swfId"]&&window["swfId"].forJSStop)window["swfId"].forJSStop();//ie
     else if(Showbo.$("swfId").forJSStop)Showbo.$("swfId").forJSStop();
     else if(document["swfId"]&&document["swfId"].forJSStop)document["swfId"].forJSStop();//ff
    }
      

  7.   

    话说,removeChild在ie中不好用,在ie中可以这么做 div.innerHTML=""; div=null;
      

  8.   

    看了下LZ的问题LZ的目的其实就是要关闭FLV吧
    flv文件应该是在FLASH里播放的 这个FLASH应该提供了 JS的控制方法 比如关闭 开始等方法
    LZ向这个方向去查找
      

  9.   

    关键是如何关闭flv播放吧,至于层嘛,还是隐藏的话,没必要销毁掉
      

  10.   

    flv需要提供一个方法让JS可以调用,并且关闭它,点击关闭的时间让JS调用它的那个方法关闭声音。因为即使你把这个DOM节点从整个DOM树上移除了,它还是没有被回收,也就是说内存中还是存在的那么还是有可能会有声音的,不同的浏览器对SWF的display:none处理方法不一致,display在FF是可以让它不再播放声音,可IE下好像不一定可以(和IE浏览器版本好像有点关系)
      

  11.   

    有几种办法,一种是remove,另一种是销毁(这种比较适合那种类似对象的)
      

  12.   


    是要修改JS里面的代码吗? 我不知道怎么修改啊,JS里面的代码是这样的:
    if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;麻烦帮我看一下,这里面需要修改吗?谢谢你啊!!!我看了这么多热心朋友的回答,虽然有点思路,但问题是,我不知道从何下手,也许这对你们来说,真的很简单,可我偏偏就不会,也不懂,所以还得请你们帮帮忙啊~~~~~ 谢谢了!
      

  13.   

    把你整个页面包括flv都提供上来,这样子很难帮你解决,说了思路你也不懂~
      

  14.   

    播放FLV一般用SWF写个播放器就行了 
    至于删除:div.innerHTML="" 这样呢
      

  15.   

    把你代码和flv上传到csdn资源上,然后提供下载链接
      

  16.   

    http://download.csdn.net/source/2510164好人,先谢谢你啊
      

  17.   

    <div id="flv">
    //视频
    </div>script:
    document.getElementById("flv").innerHTML="";
    document.getElementById("flv").style.display="none";
      

  18.   

    你的页面代码改为如下 主要是改了MM_showHideLayers这个方法的第一个参数<body onload="MM_CheckFlashVersion('7,0,0,0','本页内容需要使用较新的 Macromedia Flash Player 版本。是否现在下载它?');">
    <div align="center">
      <div id="Layer1">
        <table width="700" border="1" cellpadding="0" cellspacing="0" bordercolor="#808080">
          <tr>
            <td><table width="700" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td><div align="right"><img src="searchb7.gif" width="30" height="30" style="cursor:hand" onclick="MM_showHideLayers('container','','hide')" /></div></td>
                </tr>
              </table>
                <table width="700" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="380"><div align="left"><span class="STYLE1">&nbsp;&nbsp;&nbsp;</span></div></td>
                    <td width="380"><div align="left"></div></td>
                    <td width="40"><div align="right"></div></td>
                  </tr>
                  <tr>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                  </tr>
                  <tr>
                    <td width="380"><div align="left"><span class="STYLE2">&nbsp;&nbsp;</span></div></td>
                    <td width="380"><div align="center"></div></td>
                    <td width="40">&nbsp;</td>
                  </tr>
                </table>
              <table width="550" height="350" border="1" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td><div id="container"><a href="http://www.macromedia.com/go/getflashplayer"></div>
                        <script type="text/javascript" src="swfobject.js"></script>
                        <script type="text/javascript">
                    var s1 = new SWFObject("player.swf","ply","628","400","9","#FFFFFF");
                    s1.addParam("allowfullscreen","true");
                    s1.addParam("allowscriptaccess","always");
                    s1.addParam("flashvars","file=video_2.flv");
                    s1.write("container");
                            
                  </script>
                      &nbsp;</td>
                  </tr>
                </table>
              <table width="550" height="26" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td class="STYLE1"><div align="center">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </div></td>
                  </tr>
                </table>
              <div align="right"></div></td>
          </tr>
        </table>
      </div>
    </div>
    <p align="center">&nbsp;</p>
    </body>
    </html>我没发现你上传的页面中有MM_showHideLayers这个方法,我加了一个进去,把下面的代码加入到页面最底部<script type="text/javascript">
        function MM_showHideLayers() { //v3.0
            var i, p, v, obj, args = MM_showHideLayers.arguments;
            for (i = 0; i < (args.length - 2); i += 3) if ((obj = MM_findObj(args[i])) != null) {
                v = args[i + 2];
                if (obj.style) { obj = obj.style; v = (v == 'show') ? 'visible' : (v = 'hide') ? 'hidden' : v; }
                obj.visibility = v;
            }        document.getElementById("container").removeChild(document.getElementById("ply"));
        }    function MM_findObj(n, d) { //v4.01
            var p, i, x; if (!d) d = document; if ((p = n.indexOf("?")) > 0 && parent.frames.length) {
                d = parent.frames[n.substring(p + 1)].document; n = n.substring(0, p);
            }
            if (!(x = d[n]) && d.all) x = d.all[n]; for (i = 0; !x && i < d.forms.length; i++) x = d.forms[i][n];
            for (i = 0; !x && d.layers && i < d.layers.length; i++) x = MM_findObj(n, d.layers[i].document);
            if (!x && d.getElementById) x = d.getElementById(n); return x;
        }
    </script>
    这样子以后,点击右上角的X就可以把音乐停止掉了
      

  19.   

    起作用的就是
    document.getElementById("container").removeChild(document.getElementById("ply"));
    document.getElementById("container")这个是你的层
    document.getElementById("ply")这个就是你的播放器。
    因为你的代码中创建播放器的时候是
    var s1 = new SWFObject("player.swf","ply","628","400","9","#FFFFFF");
    第二个参数决定了这个播放器的ID就是ply