你需要創建一個線程,你的數據流來響應。 使用這樣的事情:
在你的主線程
:
while (Listening)
{
// wait for next incoming request
var result = listener.BeginGetContext(ListenerCallback, listener);
result.AsyncWaitHandle.WaitOne();
}
在類的地方:
public static void ListenerCallback(IAsyncResult result)
{
var listenerClosure = (HttpListener)result.AsyncState;
var contextClosure = listenerClosure.EndGetContext(result);
// do not process request on the dispatcher thread, schedule it on ThreadPool
// otherwise you will prevent other incoming requests from being dispatched
ThreadPool.QueueUserWorkItem(
ctx =>
{
var response = (HttpListenerResponse)ctx;
using (var stream = ...)
{
stream.CopyTo(response.ResponseStream);
}
response.Close();
}, contextClosure.Response);
}
所以......你要創建一個信息流連接,下一步將是將文件分割成單獨的包並同時發送,並在客戶端重新構建它們......爲什麼不這樣做? –
投放的視頻文件顯示在Web瀏覽器(壁虎FX),當視頻(MP4)請求時(HTML5