We\'re using a FileStreamResult to provide video data to a Silverlight MediaElement based video player:
public ActionResult Preview(Guid id) {
return new Fil
There is a project on CodePlex which gives this exact functionality.
http://mediastreamingmvc.codeplex.com/
Take a look. It was created specifically for this scenario where you want to have an action representing a request for a virtual resource and return partial content if so requested without requiring the developer to do much to support it (an Action Filter and choice of Result types.)
Then you need to reimplement throttling module :)
The idea is to calculate bitrate of your video stream and then send as much as required to client. So you need (very briefly) to read a block from your stream and send it to client and sleep for a second.
Thread.Sleep(1000) is not really a good idea for handling IIS resources so you need to do stuff in async way. IAsyncResult will be your friend.
There is much room for all kinds of optimisations.
And the last thing... I made it working as plain httphandler, not as MVC ActionResult. If it's possible in your webiste, I'm recommending to do it as a handler.