ここに私のアイデアがあります:1。無料ホスティングから私のサーバーへのリーチビデオ(OK)例:http://yanoshop.com/dms/xem/dms.aspx ?url = http://up.4share.vn/f/3103020403020003 /3830e2bfe4bdc4091f28a94d1fb9bf3d.webm.file 2.次に、サーバーからクライアントにファイルをストリーミングします(FireFoxとChromeではOKですが、IE)例:http ://www.yanoshop.com/dms/xem/webm.aspx?u = http:// yanoshop.com/dms/xem/dms.aspx?url=http://up.4share.vn/f/3103020403020003/3830e2bfe4bdc4091f28a94d1fb9bf3d.webm.file
注:これはHTML5を使用してモバイルで実行しています(VideoJSプラグインを使用しています)
ここで私が使用するコード:
//Create a stream for the file
Stream stream = null;
//This controls how many bytes to read at a time and send to the client
int bytesToRead = 50000;
// Buffer to read bytes in chunk size specified above
byte[] buffer = new Byte[bytesToRead];
// The number of bytes read
try
{
//Create a WebRequest to get the file
HttpWebRequest fileReq = (HttpWebRequest)HttpWebRequest.Create(downloadLink);
fileReq.Timeout = 99999;
//Create a response for this request
HttpWebResponse fileResp = (HttpWebResponse)fileReq.GetResponse();
if (fileReq.ContentLength > 0)
fileResp.ContentLength = fileReq.ContentLength;
//Get the Stream returned from the response
stream = fileResp.GetResponseStream();
// prepare the response to the client. resp is the client Response
Response.Clear();
Response.AddHeader("Pragma", "public");
Response.Expires = 0;
Response.AddHeader("Cache-Control", "no-cache, must-revalidate");
Response.AddHeader("Cache-Control", "public");
Response.AddHeader("Content-Description", "File Transfer");
Response.Cache.SetCacheability(HttpCacheability.Public);
Response.Cache.SetLastModified(DateTime.Now);
//Indicate the type of data being sent
Response.ContentType = ExtentionToContentType(filename);
Response.AddHeader("Accept-Ranges", "bytes");
//Name the file
Response.AppendHeader("Content-Disposition", "filename=" + filename);
Response.AddHeader("Content-Length", fileResp.ContentLength.ToString());
//Response.AddHeader("Content-Encoding", "gzip");
//Response.AddHeader("Accept-Header", stream.Length.ToString());
int length;
int count = 0;
if (count == 0)
{
}
do
{
// Verify that the client is connected.
if (Response.IsClientConnected)
{
// Read data into the buffer.
length = stream.Read(buffer, 0, bytesToRead);
// and write it out to the response's output stream
Response.OutputStream.Write(buffer, 0, length);
// Flush the data
Response.Flush();
//Clear the buffer
buffer = new Byte[bytesToRead];
}
else
{
// cancel the download if client has disconnected
length = -1;
}
} while (length > 0); //Repeat until no data is read
}
finally
{
if (stream != null)
{
//Close the input stream
stream.Close();
}
}