5

I am using ASP.NET MVC 4 for a web site. The site manages online events for our group and gives registered users access to online materials, archives of web events and instructional videos. I have built a system for uploading and managing the videos, now I need to build the Controller Actions to send the video files to the web page. We are using VideoJS as the viewer and I am pretty happy with that right now. We need to maintain security on the files so just having the files sit at a location on the web server doesn't seem to work for us.

My main question is what is a good method for returning the files to the viewer? I am used to using ActionResult and JSONResult classes, but they don't quite seem right for video files. The files can be VERY large, sometimes up to a GB or more. I see the MVC FileResult class, the FileStreamResult class and the FileContentResult class. Which one should I use and what other considerations should I be thinking about when I build this?

I appreciate your help.

Doug

drobertson
  • 1,548
  • 3
  • 14
  • 25
  • any progress on this? – Kevkong May 14 '13 at 17:10
  • Good question. You might find these approaches helpful: http://mediastreamingmvc.codeplex.com/ http://mvcresumingactions.codeplex.com/ http://dotnetslackers.com/articles/aspnet/Range-Specific-Requests-in-ASP-NET.aspx – acarlon Aug 15 '13 at 11:00

1 Answers1

0

You most certainly should not send the entire video as a response to the viewer, as they would be waiting around for a good while for it to download. You need to stream it to them. I imagine you'd need some kind of byte stream being returned from the controller.

There's a reason that places like YouTube offer their videos via flash - because the quality and rate can be controlled easily, and it offers a certain amount of copy protection (though it is not foolproof). I just did a quick Google search, and found this:

http://www.longtailvideo.com/jw-player/download/

Might be useful, but I can't vouch for it personally!

Apparently, Razor offers it's own handling of video files, that you might find useful:

http://www.asp.net/web-pages/tutorials/files,-images,-and-media/10-working-with-video

Also, HTML5 supports video streaming (which I'm sure you knew as VideoJS uses it):

http://www.w3schools.com/html/html5_video.asp

Spikeh
  • 3,540
  • 4
  • 24
  • 49