前台点击按钮,执行js事件,跳转到后台代码:

 function funShowVideo(index) {
            var iTop = (window.screen.availHeight - 30 - 500) / 2; //获得窗口的垂直位置;
            var iLeft = (window.screen.availWidth - 10 - 660) / 2; //获得窗口的水平位置;
            window.open("ShowVideo.aspx?ShowType=" + index, "newwindow1", "width=660px,height=500px,top=" + iTop + ",left=" + iLeft + ",toolbar=no,menubar=no,scrollbars=yes,resizable=yes,location=no,status=no");
        }

 

后台接收前台传过来的参数,并执行相应代码:

if (Request.QueryString["ShowType"] != null)
                    {
                        string strType = Request.QueryString["ShowType"].ToString();
                        string strVideoPath = AppDomain.CurrentDomain.BaseDirectory + "Videos\\";//视频路径

                        \\ AppDomain.CurrentDomain.BaseDirectory:获取当前路径
                        string strVideoName = "";   //视频名称
                        string strNodeName = "";
                        if (strType == "1")
                        {
                            strNodeName = "CleanVideo";
                        }
                        else if (strType == "2")
                        {
                            strNodeName = "AjustVideo";
                        }
                        else if (strType == "3")
                        {
                            strNodeName = "ChangeVideo";
                        }
                        if (System.Configuration.ConfigurationManager.AppSettings[strNodeName] != null)
                        {
                            strVideoName = System.Configuration.ConfigurationManager.AppSettings[strNodeName].ToString();
                            strVideoPath += strVideoName;
                            if (File.Exists(strVideoPath))
                            {
                                Label2.Text = PlayMedia(strVideoPath);
                            }
                        }
                    }

 

//播放视频文件的代码

public string PlayMedia(string MediaFile)
        {
            string strScript = "";
            strScript += "<TABLE id=\"Table2\" align=\"center\" border=\"0\" runat=\"server\" width = '620' height ='450'>";
            strScript += "<TR>";
            strScript += "<TD align=\"center\">";
            strScript += "<OBJECT id=\"mdpTrailer\" classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" name=\"mdpTrailer\" width='620' height = '450'>";
            strScript += "<PARAM NAME=\"AudioStream\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"AutoSize\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"AutoStart\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"AnimationAtStart\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"AllowScan\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"AllowChangeDisplaySize\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"AutoRewind\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"Balance\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"BaseURL\" VALUE=\"\">";
            strScript += "<PARAM NAME=\"BufferingTime\" VALUE=\"5\">";
            strScript += "<PARAM NAME=\"CaptioningID\" VALUE=\"\">";
            strScript += "<PARAM NAME=\"ClickToPlay\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"CursorType\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"CurrentPosition\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"CurrentMarker\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"DefaultFrame\" VALUE=\"\">";
            strScript += "<PARAM NAME=\"DisplayBackColor\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"DisplayForeColor\" VALUE=\"16777215\">";
            strScript += "<PARAM NAME=\"DisplayMode\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"DisplaySize\" VALUE=\"4\">";
            strScript += "<PARAM NAME=\"Enabled\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"EnableContextMenu\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"EnablePositionControls\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"EnableFullScreenControls\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"EnableTracker\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"Filename\" VALUE=\"" + MediaFile + "\">";
            strScript += "<PARAM NAME=\"InvokeURLs\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"Language\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"Mute\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"PlayCount\" VALUE=\"1\">";
            strScript += "<PARAM NAME=\"PreviewMode\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"Rate\" VALUE=\"1\">";
            strScript += "<PARAM NAME=\"SAMILang\" VALUE=\"\">";
            strScript += "<PARAM NAME=\"SAMIStyle\" VALUE=\"\">";
            strScript += "<PARAM NAME=\"SAMIFileName\" VALUE=\"\">";
            strScript += "<PARAM NAME=\"SelectionStart\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"SelectionEnd\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"SendOpenStateChangeEvents\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"SendWarningEvents\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"SendErrorEvents\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"SendKeyboardEvents\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"SendMouseClickEvents\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"SendMouseMoveEvents\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"ShowCaptioning\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"ShowControls\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"ShowAudioControls\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"ShowDisplay\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"ShowGotoBar\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"ShowPositionControls\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"ShowStatusBar\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"ShowTracker\" VALUE=\"-1\">";
            strScript += "<PARAM NAME=\"TransparentAtStart\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"VideoBorderWidth\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"VideoBorderColor\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"VideoBorder3D\" VALUE=\"0\">";
            strScript += "<PARAM NAME=\"Volume\" VALUE=\"-600\">";
            strScript += "<PARAM NAME=\"WindowlessVideo\" VALUE=\"0\">";
            strScript += "</OBJECT>";
            strScript += "</TD>";
            strScript += "</TR>";
            strScript += "</TABLE>";
            return strScript;
        }