论坛交流
首页办公自动化| 网页制作| 平面设计| 动画制作| 数据库开发| 程序设计| 全部视频教程
应用视频: Windows | Word2007 | Excel2007 | PowerPoint2007 | Dreamweaver 8 | Fireworks 8 | Flash 8 | Photoshop cs | CorelDraw 12
编程视频: C语言视频教程 | HTML | Div+Css布局 | Javascript | Access数据库 | Asp | Sql Server数据库Asp.net  | Flash AS
当前位置 > 文字教程 > Asp.net教程
Tag:静态页面,treeview,gridview,repeater,dataset,sqldatareader,ado.net,上传,三层,ajax,xml,留言本,新闻发布,商城,注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,触发器,socket,form认证,登录,视频教程

Asp.net FMS 开发视频网站

文章类别:Asp.net | 发表日期:2008-10-5 21:54:36

开发步骤:
1。下载FMS http://blogs.ugidotnet.org/kfra/archive/2006/10/04/50003.aspx,安装配置。
2。使用flash制作FMS视频采集的控件。
3。aspx页面嵌入FMS采集控件,运行采集数据上传到FMS服务器,修改数据库的视频文件存放地址。
4。页面嵌入Flash播放控件,加入FLV处理流代码:

 1using System;
 2using System.IO;
 3using System.Web;
 4
 5
 6/**//// <summary>
 7/// Summary description for FLVStreaming
 8/// </summary>
 9public class FLVStreaming : IHttpHandler
10{
11    private static readonly byte[] _flvheader = HexToByte("464C5601010000000900000009"); //"FLV\x1\x1\0\0\0\x9\0\0\0\x9"
12
13    public FLVStreaming()
14    {
15    }
16
17    public void ProcessRequest(HttpContext context)
18    {
19        try
20        {
21            int pos;
22            int length;
23
24            // Check start parameter if present
25            string filename = Path.GetFileName(context.Request.FilePath);
26
27            using (FileStream fs = new FileStream(context.Server.MapPath(filename), FileMode.Open, FileAccess.Read, FileShare.Read))
28            {
29                string qs = context.Request.Params["start"];
30
31                if (string.IsNullOrEmpty(qs))
32                {
33                    pos = 0;
34                    length = Convert.ToInt32(fs.Length);
35                }
36                else
37                {
38                    pos = Convert.ToInt32(qs);
39                    length = Convert.ToInt32(fs.Length - pos) + _flvheader.Length;
40                }
41
42                // Add HTTP header stuff: cache, content type and length       
43                context.Response.Cache.SetCacheability(HttpCacheability.Public);
44                context.Response.Cache.SetLastModified(DateTime.Now);
45
46                context.Response.AppendHeader("Content-Type", "video/x-flv");
47                context.Response.AppendHeader("Content-Length", length.ToString());
48
49                // Append FLV header when sending partial file
50                if (pos > 0)
51                {
52                    context.Response.OutputStream.Write(_flvheader, 0, _flvheader.Length);
53                    fs.Position = pos;
54                }
55
56                // Read buffer and write stream to the response stream
57                const int buffersize = 16384;
58                byte[] buffer = new byte[buffersize];
59               
60                int count = fs.Read(buffer, 0, buffersize);
61                while (count > 0)
62                {
63                    if (context.Response.IsClientConnected)
64                    {
65                        context.Response.OutputStream.Write(buffer, 0, count);
66                        count = fs.Read(buffer, 0, buffersize);
67                    }
68                    else
69                    {
70                        count = -1;
71                    }
72                }
73            }
74        }
75        catch (Exception ex)
76        {
77            System.Diagnostics.Debug.WriteLine(ex.ToString());
78        }
79    }
80
81    public bool IsReusable
82    {
83        get { return true; }
84    }
85
86    private static byte[] HexToByte(string hexString)
87    {
88        byte[] returnBytes = new byte[hexString.Length / 2];
89        for (int i = 0; i < returnBytes.Length; i++)
90            returnBytes[i] = Convert.ToByte(hexString.Substring(i * 2, 2), 16);
91        return returnBytes;
92    }
93
94}
95修改配置文件,运行页面即可调出视频,播放速度很不错。虽说轻描淡写但已经给出应用Asp.net开发视频网站的思路。如果有兴趣可以联系我。

http://www.cnblogs.com/xiucai/archive/2007/06/13/782001.html

视频教程列表
文章教程搜索
 
Asp.net推荐教程
Asp.net热门教程
看全部视频教程
购买方式/价格
购买视频教程: 咨询客服
tel:15972130058