.NET MVC流的MP4的iDevice问题问题、MVC、NET、iDevice

2023-09-05 00:44:23 作者:飞天小仙女

Ive得到了一个有点问题了一块code我一直工作在服务的视频。在code是如下:

Ive got a bit of a issue with a piece of code I've been working on to serve video. The code is below:

public ResumingFileStreamResult GetMP4Video(string videoID)
    {
        if (User.Identity.IsAuthenticated)
        {
            string clipLocation = string.Format("{0}\\Completed\\{1}.mp4", ConfigurationManager.AppSettings["VideoLocation"].ToString(), videoID);

            FileStream fs = new FileStream(clipLocation, FileMode.Open, FileAccess.Read);

            ResumingFileStreamResult fsr = new ResumingFileStreamResult(fs, "video/mp4");

            return fsr;
        }
        else
        {
            return null;
        }
    }

这是我的HTML code:

This is my HTML code:

<video controls preload poster="@Url.Content(string.Format("~/Videos/{0}_2.jpg", Model.VideoID))">
    <source src="@Url.Action("GetMP4Video", "Video", new { videoID = Model.VideoID })" type="video/mp4" />
    <source src="@Url.Action("GetWebMVideo", "Video", new { videoID = Model.VideoID })" type="video/webm" />

        <object id="flowplayer" data="@Url.Content("~/Scripts/FlowPlayer/flowplayer-3.2.14.swf")" type="application/x-shockwave-flash" width="640" height="360">
            <param name="movie" value="@Url.Content("~/Scripts/FlowPlayer/flowplayer-3.2.14.swf")" />
            <param name="allowfullscreen" value="true" />
            <param name="flashvars" value="config={'playlist':['@Url.Content(string.Format("~/Videos/{0}_2.jpg", Model.VideoID))',{'url':'@Url.Action("GetMP4Video", "Video", new { videoID = Model.VideoID })','autoPlay':false}]}" />
        </object>
</video>

我的问题是这样的设置似乎很好地工作在从我的桌面上所有的浏览器,但是当我尝试使用我的iPad或iPhone加载该页面只是显示了播放图标通过这一条线,表示它不能播放。我试图改变源MP4视频直接链接到MP4视频和立刻在iPad开始播放。

My problem is this setup seems to work fine in all browsers from my desktop but when I try to load the page using my iPad or iPhone it just shows the play icon with a line through it indicating it can't play it. I tried changing the source for the mp4 video to a direct link to the mp4 video and straight away the iPad started playing it.

有没有我需要做的,我已经错过了在责令对我的iDevices方法兼容一些特别的东西?任何帮助将AP preciated。

Is there something special I need to do that I've missed in ordered to make my method compatible for iDevices? Any help on this would be appreciated.

推荐答案

感谢您的回信和提供的资料是非常有益的。最后我用下面的解决方案执行字节范围请求。

Thanks for the replys and the information given was very helpful. In the end I used the following solution to implement byte range requests.