开发步骤: 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/**//// 7/// Summary description for FLVStreaming 8/// 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;
|