无法使用WCF服务在IOS设备上下载/流式传输视频文件

时间:2018-08-23 11:48:27

标签: c# ios wcf video stream

我正在实现一个简单的WCF服务功能,用于从服务器下载文件(主要是图像和视频),如下所示

 public Stream downloadFile(String filePath)
    {
        FileStream file = null;
        try
        {

            String appPath = System.Web.Hosting.HostingEnvironment.MapPath("~/Files");
            String filocation = Path.Combine(appPath, @filePath);
            file = File.OpenRead(filocation);
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Accept-Ranges", "bytes");
            WebOperationContext.Current.OutgoingResponse.ContentType = MimeMapping.GetMimeMapping(filePath);
            HttpContext.Current.Response.Headers.Add("Content-Length", file.Length.ToString());
            WebOperationContext.Current.OutgoingResponse.Headers.Add("Status", "200");
            HttpContext.Current.Response.Headers.Add("Cache-Control ", "private");
                }
        catch (IOException e)
        {
            Console.WriteLine("IOException : {0}", e);
        }

        return file;

    }

在web.config中用于该服务的webhttpBinding如下

<webHttpBinding>
  <binding name="WebConfiguration" 
           maxBufferSize="65536" 
           maxReceivedMessageSize="2000000000"
           transferMode="Streamed">
  </binding>

还有

<httpRuntime targetFramework="4.5.2" maxRequestLength="67108864"/>

该服务功能可在PC和所有Android设备上针对所有文件正常运行,但无法在IOS设备上使用此功能播放/下载视频。

我已经实现了Http Range标头,以检查这是否是一个问题,但是没有解决。我不知道IOS设备出了什么问题,没有传输/下载视频文件。

任何解决此问题的方法?谢谢。

0 个答案:

没有答案