asp.net FMS Development video site

Source: Internet
Author: User

Development steps:

1. Download FMS http://blogs.ugidotnet.org/kfra/archive/2006/10/04/50003.aspx, installation configuration.

2. Use Flash to make FMS video capture controls.

3. The ASPX page embeds the FMS collection control, runs the collection data to the FMS server, modifies the database's video file storage address.

4. The page embeds the Flash playback control and adds the FLV process Flow code:

1using System;


2using System.IO;


3using system.web;


4


5


6/**////<summary>


7///Summary description for flvstreaming


8///</summary>


9public class Flvstreaming:ihttphandler


10{


private static readonly byte[] _flvheader = Hextobyte ("464c5601010000000900000009"); "Flv\x1\x1\0\0\0\x9\0\0\0\x9"


12


public flvstreaming ()


14 {


15}


16


public void ProcessRequest (HttpContext context)


18 {


Try


20 {


int POS;


int length;


23


//Check start parameter if present


string filename = path.getfilename (context. Request.filepath);


26


using (FileStream fs = new FileStream (context). Server.MapPath (filename), FileMode.Open, FileAccess.Read, FileShare.Read)


28 {


string qs = context. request.params["Start"];


30


to if (string. IsNullOrEmpty (QS))


32 {


pos = 0;


length = Convert.ToInt32 (fs. Length);


35}


or Else


37 {


pos = Convert.ToInt32 (QS);


length = Convert.ToInt32 (fs. Length-pos) + _flvheader. Length;


40}


41


I//Add HTTP header Stuff:cache, content type and length


. Response.Cache.SetCacheability (Httpcacheability.public);


. Response.Cache.SetLastModified (DateTime.Now);


45


. Response.appendheader ("Content-type", "video/x-flv");


. Response.appendheader ("Content-length", Length. ToString ());


48


//Append FLV Header when sending partial file


if (pos > 0)


51 {


. Response.OutputStream.Write (_flvheader, 0, _flvheader. Length);


FS. Position = pos;


54}


55


/Read buffer and write stream to the response stream


const int buffersize = 16384;


byte[] buffer = new Byte[buffersize];


59


int count = fs. Read (buffer, 0, buffersize);


(Count > 0)


62 {


-if (context. response.isclientconnected)


64 {


the context. Response.OutputStream.Write (buffer, 0, count);


count = fs. Read (buffer, 0, buffersize);


67}


or Else


69 {


count =-1;


71}


72}


73}


74}


catch (Exception ex)


76 {


System.Diagnostics.Debug.WriteLine (ex. ToString ());


78}


79}


80


Bayi public bool IsReusable


82 {


the get {true;}


84}


85


private static byte[] Hextobyte (string hexstring)


87 {


byte[] returnbytes = new BYTE[HEXSTRING.LENGTH/2];


for (int i = 0; i < returnbytes.length; i++)


Returnbytes[i] = Convert.tobyte (hexstring.substring (i * 2, 2), 16);


return returnbytes;


92}


93


94}


95

Modify the configuration file, run the page to pull out the video, playback speed is very good. Although the understatement but has given the application asp.net development video website idea. If you are interested, you can contact me.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.