.net利用本地播放器播放视频文件代码

前台点击按钮,执行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;
        }

时间: 2024-10-12 04:17:49

.net利用本地播放器播放视频文件代码的相关文章

使用scratch3.0制作《礼佛大忏悔文》播放器及视频

使用scratch3.0制作<礼佛大忏悔文>播放器及视频 缘起 缘起: 拜忏的音乐不能自由定制,做视频和音频处理又很专业,普通人只能望而兴叹. 目的: 由<礼佛大忏悔文>做为因子,通过一个小时的学习,让大家掌握音频.视频的基本制作,能通过软件录制一个自己定制的<礼佛大忏悔文>软件. 推而广之,可以进行<弟子规><岳阳楼记><桃花源记>等等的视频MV的录制. 使用工具: scratch 3.0 下载地址 用于程序生成忏悔文所有动画.音频

Fedora 21 解决播放器播放mp4、rmvb格式媒体文件

新安装了fedora21 workstation,第一件事情解决播放器播放mp4.rmvb文件. 当你打开默认播放器尝试播放一个mp4文件时,会提示缺少xxx,提示你搜索,点击[搜索],搜索出一大堆东西,点击[安装].一切似乎都非常顺利,可是一切都是徒劳.当你再次尝试播放时,依然会提示上面的步骤,只不过最后会提示你已经安装.无法再次安装. 于是,我想起原先fedora19时,我的解决办法,就是直接安装kmplayer就好了. sudo yum intall *Kmplayer* 但是这次,成功安

HTML5隐藏播放器播放背景音乐

<audio controls autoplay> <source src="1.mp3" type="audio/mpeg" > 您的浏览器不支持 audio 元素. </audio> HTML5隐藏播放器播放背景音乐 html5添加网页背景音乐 一个客户要求给网站添加一个背景音乐,我用的是html5添加网页背景音乐的代码,在此记录一下以后有用. html5方法一:<audio autoplay="" 

HTML中的Flash播放器播放M3U8格式的视频

M3U8 TEST <!DOCTYPE html> <html> <head> <title>M3U8 TEST</title> </head> <body> <div id="player"> </div> </body> </html> HTML代码 <script src="lib/swfobject.js"><

音乐播放器:打开文件对话框

制作了一个简单的音乐播放器.具有打开电脑里面的文件,选择歌曲播放 主要是为了掌握,打开文件夹,选择文件的 1 private void Frm_Load(object sender, EventArgs e) 2 { 3 skinEngine1.SkinFile = "DiamondBlue.ssk"; 4 5 MediaPlayer1.settings.autoStart = false;//禁止加载时就播放 6 MediaPlayer1.URL = "F:\\QQPCmg

Android播放器实现视频窗口实时放大缩小功能

很多开发者希望Android播放端实现视频窗口的放大缩小功能,为此,我们做了个简单的demo,通过播放端回调RGB数据,直接在上层view操作处理即可,Github:https://github.com/daniulive/SmarterStreaming 无视频无真相:http://www.iqiyi.com/w_19s9sa7epp.html 基本流程如下: 1. 基础的初始化和参数设定 libPlayer = new SmartPlayerJniV2(); myContext = this

libvlc —— 播放器示例程序[C++代码实现攫取 RGB图像 和 PCM音频 数据功能]

在我以前的实际项目中,曾利用 libvlc 去解码音视频媒体数据(如 RTSP.本地文件 等),通过其提供的回调函数接口,攫取 RGB图像 进行图像分析,如 人脸识别.运动检测 等一类的产品应用.除此之外,只要提供适当的 MRL,配合选项参数,VLC 还可以进行屏幕录制.摄像头图像采集.麦克风音频采集 等功能. 我在网上参看过很多人提供的示例源码,实现流程都很初潜,只适合当作学习的 Demo 来看,与实际的项目应用还有很多问题要解决.为此,在这里公开我封装 libvlc 的 C++ 类,方便TA

十二篇、HTML5隐藏播放器播放背景音乐

html5添加网页背景音乐 一个客户要求给网站添加一个背景音乐,我用的是html5添加网页背景音乐的代码,在此记录一下以后有用. html5方法一:<audio autoplay="" loop=""><source src="http://mi.0w0.im/Letter_Song.mp3 "></audio>不显示播放器. html5方法二:<video controls="" a

网页中插入VLC播放器播放rtsp视频流步骤

1.      仿照http://download.csdn.net/detail/haowenxin123456789/8044245 中步骤: 2.      从http://www.videolan.org/vlc/index.html  中下载 vlc-2.2.1-win32.exe 并安装到D:\\ProgramFiles文件夹下: 3.  运行:vegsvr32  D:\\ProgramFiles\\VideoLAN\\VLC\\axvlc.dll : 4.  test.html 文