Laxman Dussa

Laxman Dussa

  • NA
  • 117
  • 4.3k

MVC with Jquery

Dec 17 2018 5:32 AM
how to upload MP4 Video files, save (insert) to database table, retrieve (display) files from database table using Entity Framework and play the files with Live Streaming from database table using HTML5 Video Player in ASP.Net MVC jquery Pleasse sent Simple code
 
my code is
  1. [HttpPost]  
  2. public FileResult DisplayImage(string name,string email)  
  3. {  
  4. byte[] data;  
  5. UserImage user = db.UserTable.Where(X => X.UserName == name && X.Email == email).FirstOrDefault();  
  6. if (user!= null)  
  7. {  
  8. string imreBase64Data = Convert.ToBase64String(user.photos);  
  9. //string imgDataURL = string.Format("data:image/png;base64,{0}", imreBase64Data);  
  10. string audioDataURL = string.Format("data:audio/mp3;base64,{0}", imreBase64Data);  
  11. //return Json(new { data = audioDataURL }, JsonRequestBehavior.AllowGet);  
  12. data = (byte[])user.photos;  
  13. return File(data, "audio/mp3");  
  14. }  
  15. return null;  
  16. }  
SCRIPT
  1. <script>  
  2. $(function () {  
  3. alert("hai")  
  4. $.get("/Home/DisplayAudio?id='" + 2006 + "'"function (response) { audio.src = 'data:audio/mp3;base64,' + response.data + ''; })  
  5. //$.ajax({  
  6. // type: "POST",  
  7. // url: "/Home/DisplayAudio",  
  8. // data: " {id:'" + $("#txtid").val() + "'}",  
  9. // contentType: "application/json; charset=utf-8",  
  10. // dataType: "File",  
  11. // success: function (data, status) {  
  12. // alert("hai")  
  13. // $.each(data, function (index, value) {  
  14. // // audio.src = 'data:audio/jpg;base64,' + value.data + ' type = "audio/mp3";  
  15. // audio.src = 'data:audio/mp3;base64,'+ value.data + '';  
  16. // })  
  17. // }  
  18. //})  
  19. })  
  20. </script>  
  21. <body>  
  22. <input id="txtid" /><br />  
  23. <input type="submit" value="Submit" id="btnPost" onclick="InsertData()" />  
  24. <audio controls>  
  25. <source src="" />  
  26. </audio>  
  27. </body>  

Answers (1)