아래 코드를 사용하여 SQL Server의 .flv 비디오를 스트리밍하고 있습니다. 그러나 내가 이해하는 것으로부터 전체 비디오는 재생되기 전에 메모리에로드 될 것입니다. 내가 뭘하고 싶은 SQLDataReader에 CommandBehavior.SequentialAccess를 추가하는 것입니다 ...하지만 그것을 작동시킬 수 없습니다.비디오 스트림에 순차 액세스를 어떻게 추가합니까?
여기 도와주세요. 광산에 적용 할 수있는 실제 사례를 제공 할 수 있다면 행복 할 것입니다. Psuedo 코드가 차선책 일 것입니다. 모든 포인터는 비록 감사하지만.
은 여기 내 HttpHandler를
public class ViewFilm : IHttpHandler
{
public void ProcessRequest(HttpContext context)
{
try
{
// Check if video id was given
if (context.Request.QueryString["id"] != null)
{
string video_ID = context.Request.QueryString["id"];
// Connect to DB and get the video
using (SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["ApplicationServices"].ConnectionString))
using (SqlCommand cmd = new SqlCommand("GetVideo", con))
{
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter sqlParam = cmd.Parameters.Add("@videoId", SqlDbType.Int);
sqlParam.Value = video_ID;
con.Open();
using (SqlDataReader dr = cmd.ExecuteReader())
{
if (dr.HasRows)
{
dr.Read();
// Add HTTP header: cache, content type and length
context.Response.Cache.SetCacheability(HttpCacheability.Public);
context.Response.Cache.SetLastModified(DateTime.Now);
context.Response.AppendHeader("Content-Type", "video/x-flv");
context.Response.AppendHeader("Content-Length", ((byte[])dr["data"]).Length.ToString());
context.Response.BinaryWrite((byte[])dr["data"]);
}
}
}
}
}
catch (Exception ex)
{
throw new Exception(ex.ToString());
}
}
public bool IsReusable
{
get { return false; }
}
}
DB에서 스트리밍 비디오가 처음에는 좋은 생각이라고 생각하지 않습니다. 디자인을 다시 생각해보십시오. – BrokenGlass
그냥 수업을 종료하고 내 의견을 삭제했습니다. 내 잘못이야. – Niklas