流视频无法在IE中运行

时间:2012-07-28 08:56:31

标签: asp.net streaming video.js

这是我的想法: 1.从免费托管到我的服务器的Leech视频(OK) 示例:http://yanoshop.com/dms/xem/dms.aspx?url=http://up.4share.vn/f/3103020403020003/3830e2bfe4bdc4091f28a94d1fb9bf3d.webm.file 2.然后从服务器到客户端的流媒体文件(在FireFox和Chrome上可以,但是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在Mobile上运行(我正在使用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();
            }
        }

1 个答案:

答案 0 :(得分:0)

看起来你正在使用一个WebM文件,Chrome和Firefox支持这个文件,但IE9没有。