简体   繁体   中英

ASP.NET MVC : Video streaming from SQL Server

I am trying to retrive FLV video that stored in SQL Server database and displaying it using JWplayer plugin. When I run I get this error :

task queue failed at step 5 playlist file did not contain a valid playlist

My Code :

    [AcceptVerbs(HttpVerbs.Get)]

    public ActionResult GetVideo(int id)
    {



        byte[] contents =_contentAssestTask.GetItem(id).FileContent;

        var ms = new MemoryStream();


        ms.Write(contents, 0, contents.Length);
        ms.Position = 0;

Response.Cache.SetCacheability(HttpCacheability.Public);
        Response.Cache.SetLastModified(DateTime.Now);
        Response.AppendHeader("Content-Type", "video/x-flv");
        Response.AppendHeader("Content-Length", contents.Length.ToString());

        return new FileStreamResult(ms, "video/x-flv");



    }

and view contains :

    <script type="text/javascript" src="@Url.Content("~/Scripts/jwplayer.js")"> </script>

<div id='mediaplayer'></div>
<script type="text/javascript">
  jwplayer('mediaplayer').setup({
    'flashplayer': '@Url.Content("~/Content/Video/player.swf")',
    'id': 'playerID',
    'width': '480',
    'height': '270',
    'file': '@Url.Action("GetVideo","MultiMedia",new {id=2})',
    'image': '',
    'plugins': {
       'viral-2': {
           'onpause': 'false',
           'callout': 'none'
       }
    }
  });
</script>

您必须设置id:“ playerID”,键入:“ mp4”,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM