I am using asp.net mvc, and I'd like to add media player control in my view page, so how do I do that?
+4
A:
My first three google finds:
1) A control (doesn't know if it works with mvc though)
http://www.beansoftware.com/free-asp.net-controls/asp.net-media-player-control.aspx
2) Silverlight Player
http://www.asp.net/aspnet-in-net-35-sp1/videos/introduction-to-the-aspnet-mediaplayer-control
3) Embed if it doesnt matter which mediaplayer will be used:
<embed id="videocontent" width="550" height="480" type="video/avi" autstart="true" loop="false" runat="server" style="border: gray 1px solid"></embed>.
or in valid xhtml
<object classid="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95" id="player" width="320" height="260">
<param name="url" value="<%= ViewData["src"] %>" />
<param name="src" value="<%= ViewData["src"] %>" />
<param name="showcontrols" value="true" />
<param name="autostart" value="true" />
<!--[if !IE]>-->
<object type="video/x-ms-wmv" data="<%= ViewData["src"] %>" width="320" height="260">
<param name="src" value="<%= ViewData["src"] %>" />
<param name="autostart" value="true" />
<param name="controller" value="true" />
</object>
<!--<![endif]-->
</object>
Christina Mayers
2010-06-08 11:40:37
A:
+1 to Christina, but #1 may not work in an MVC app.
Her answers, plus you'll want to create a controller action that returns a FileResult. Check this question (its about an image, but a file is a file all the web round):
http://stackoverflow.com/questions/186062/can-an-asp-net-mvc-controller-return-an-image
Will
2010-06-08 11:57:59
Is there a reason to not store the video in the content folder (or any folder with IgnoreRoute)? If he wants to just play the video (eg don't need to count views, access control etc)
Christina Mayers
2010-06-08 12:10:08
@Christina, depends on his architecture in the end. Of course, ASP.NET MVC requests all get served via ASP.NET, so you don't gain much by dumping files in a directory. If there is any logic behind how they are handled or if he wishes to use routes to identify the files, however, he'll have to express that within a controller action.
Will
2010-06-08 12:22:54