Click here to Skip to main content
15,567,221 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Hi..
I have audio and video file which comes from MS SQL database i want to play it on browser using mvc application how should i play it??
Posted
Updated 11-Aug-16 4:19am
v2

1 solution

Use the HTML5 <video> and <audio> elements:
Using HTML5 audio and video - Web developer guides | MDN[^]

You'll need to make sure you have the relevant formats required to support different browsers:
Media formats supported by the HTML audio and video elements - HTML | MDN[^]

To load the video / audio file, you'll need an action which returns the file data:
C#
public ActionResult Video(int id)
{
    var videoData = ...; // Load the bytes for the specified video from the database
    return File(videoData, "video/mp4");
}

ASP.NET
<video controls autoplay>
  <source src="@Url.Action("Video", "YourController", new { id = Model.VideoId })" type="video/mp4" />
  (Fallback content for old browsers...)
</video>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900