TOP

[ASP.Net] stream video content in asp.net

stream video content in asp.net 

方法一:
byte[] buffer = new byte[4096];

while(true) {
    int bytesRead = myStream.Read(buffer, 0, buffer.Length);
    if (bytesRead == 0) break;
    Response.OutputStream.Write(buffer, 0, bytesRead);
}

參考資料:
http://stackoverflow.com/questions/2687677/how-to-stream-video-content-in-asp-net

方法二:
VB.Net:

Using req As WebRequest = HttpWebRequest.Create("url here"), _
      stream As Stream = req.GetResponse().GetResponseStream()

End Using

C#:

WebRequest req = HttpWebRequest.Create("url here");
using (Stream stream = req.GetResponse().GetResponseStream() )
{

}

參考資料:
http://stackoverflow.com/questions/1223311/is-it-possible-to-read-from-a-url-into-a-system-io-stream-object


0 意見:

張貼留言