asp.net调用windows系统自动的播放器Media player

 前台代码

<embed src="<%=VUrl%>" noerror="true" style="width: 579px; height: 321px"></embed>

 

后台代码

  //观看视频
    protected void seeVi()
    {
        try
        {
            string sql = "select * from tb_Video where VideoID=" + Convert.ToInt32(Request.QueryString["VideoID"]);
            OleDbDataReader odr = mydo.row(sql);//调用数据库操作类中的row方法         
            odr.Read();          //前进一条记录
            VUrl = "Video" + "\\" + odr["VideoUrl"].ToString();   //存储视频教程的路径
            if (!File.Exists(Server.MapPath(".") + "\\" + VUrl))//判断此教程是否存在
            {
                string dlsql = "delete from tb_Video where VideoID=" + Convert.ToInt32(Request.QueryString["VideoID"]);
                mydo.adlData(dlsql);
                Page.RegisterStartupScript("true", "<script>alert('文件不存在!请返回!');location='index.aspx'</script>");
            }
            VideoTitle = odr["VideoName"].ToString();
            Content = odr["VideoContent"].ToString();
            Name = odr["Name"].ToString();
            FBDate = odr["FBDate"].ToString();
            ClickSum = odr["ClickSum"].ToString();
        }
        catch (Exception ex)
        {
            Response.Write(ex.Message.ToString());
        }
    }

文件下载:

if (Session["UserName"] != null)
        {
            string path = Server.MapPath(".\\") + VUrl;
            //初始化 FileInfo 类的实例,它作为文件路径的包装
            FileInfo fi = new FileInfo(path);
            Response.Write(path);
            //   判断文件是否存在
            if (fi.Exists)
            {
                // 将文件保存到本机上
                Response.Clear();
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(fi.Name));
                Response.AddHeader("Content-Length", fi.Length.ToString());
                Response.ContentType = "application/octet-stream";
                Response.Filter.Close();
                Response.WriteFile(fi.FullName);
                Response.End();
            }

 

转载于:https://www.cnblogs.com/xiachufeng/archive/2010/07/01/1769120.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值