How to stream partial content with ASP.NET MVC FileStreamResult

前端 未结 3 1179
感动是毒
感动是毒 2021-02-20 06:46

We\'re using a FileStreamResult to provide video data to a Silverlight MediaElement based video player:

public ActionResult Preview(Guid id) {
    return new Fil         


        
3条回答
  •  你的背包
    2021-02-20 07:07

    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.

提交回复
热议问题