如何通过从数据库获取流来使用HTML5视频标记在MVC 5,C#中播放视频 [英] How to play video in MVC 5, C# , with HTML5 video tag by getting stream from database

查看:296
本文介绍了如何通过从数据库获取流来使用HTML5视频标记在MVC 5,C#中播放视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个控制器动作,它将视频流数据(MP4格式)返回到cshtml视图页面中的视频标签。

但是视频没有播放。有时它在IE11中播放,但在任何其他浏览器中都没有播放。通过谷歌搜索,我知道需要对流数据进行编码。

我不明白编码是什么以及如何编码?我试过搜索,但是得到任何明确的观点。

我通过将视频文件转换为字节数组来保存数据库中的视频文件。在检索时,我将带有文件格式的字节数组作为文件发送到操作结果中。还有什么需要做的吗?



还有哪些C#dll可以在C#中进行编码而不是使用外部/第三方应用程序?



这是我的代码。



控制器动作 -

Hi ,
I have a controller action with returns a video stream data(MP4 format) to a video tag in cshtml view page.
But video is not playing. Some times it is playing in IE11, but not at all playing in in any other browser. By searching in google I got to know that stream data need to be encoded.
I don't understand what is to encode and how? I have tried searching but dint get any clear point on that.
I am saving the video file in database by converting it into byte array. While retrieving I am sending the byte array with file format in action result as a File. What else needs to be done here?

More over are there any C# dlls available which can do the encoding in C# instead of using external/ 3rd party applications?

this is my code.

controller action -

public ActionResult GetSearchResults(int id)
       {
           SearchService call = new SearchService();
            var result = call.GetData(id);
           return File(result.File , result.fileType);
       }



html代码 -


html code -

<video id='videoobj' width='400'  height='400' type='video/mp4' src='some server path /GetSearchResults/" + id + "'/>





请以正确的方式指导我如何在支持HTML5的所有浏览器中播放此视频流。



谢谢。



Kindly guide me in right way how to achieve this video stream to play in all browsers which supports HTML5.

Thanks.

推荐答案

https://code.msdn。 microsoft.com/MVC4-Play-video-stream-56473266 [ ^ ]

http://www.aspsnippets.com/Articles/Upload-Save-Retrieve-and-Play -MP4-video-files-with-streaming-from-Database-in-ASPNet-using-C-and-VBNet.aspx [ ^ ]



这将解决您的查询:)



-KR
https://code.msdn.microsoft.com/MVC4-Play-video-stream-56473266[^]
http://www.aspsnippets.com/Articles/Upload-Save-Retrieve-and-Play-MP4-Video-files-with-live-streaming-from-Database-in-ASPNet-using-C-and-VBNet.aspx[^]

This would solve your query :)

-KR


这篇关于如何通过从数据库获取流来使用HTML5视频标记在MVC 5,C#中播放视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆