I am trying to write a video streaming site using an embedded VLC control to play the video and an asp.net handler to get the video stream. I am embedding the control as follows:
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" width="640" height="480" target="http://MyWebsite/MyHandler.ashx"/>
<object classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://download.videolan.org/pub/videolan/vlc/last/win32/axvlc.cab"></object>
And the code i am using in the handler to stream the video is:
public void ProcessRequest(HttpContext context)
{
context.Response.Buffer = false;
context.Response.ContentType = "text/plain";
var path = @"c:/file.avi";
var file = new FileInfo(path);
var len = (int)file.Length;
context.Response.AppendHeader("content-length", len.ToString());
var buffer = new byte[1024];
var outStream = context.Response.OutputStream;
using (Stream stream = File.OpenRead(path))
{
int bytes;
while (len > 0 && (bytes = stream.Read(buffer, 0, buffer.Length)) > 0)
{
outStream.Write(buffer, 0, bytes);
len -= bytes;
}
}
}
While this works and streams the video, I am unable to seek back or forward, the seek bar doesn't move at all. I thought since I sent the file size it would be able to calculate positions but I guess not. Is it possible to seek in the video or will it not be possible since it is a stream (even though it is not a 'true' stream since it is coming from a file with a defined size etc)
来源:https://stackoverflow.com/questions/21635821/streaming-video-to-embedded-vlc-via-asp-net-unable-to-seek-position