在Asp.NET Core 2.0中的Safari/iOS设备上无法播放视频文件流 [英] Video File streaming not working on Safari/ iOS device in asp.NET Core 2.0
问题描述
我在asp.net core 2.0中创建了API,该API返回视频文件流结果.以下是用于返回文件流结果的代码示例.该网址在Chrome上正常运行,但在iOS设备和Safari浏览器上不起作用.
I have created the API in asp.net core 2.0 that returns the video file streaming Result. Below is the code sample for returning the filestream result. The URL is working fine on Chrome but the URL will not work on iOS device and Safari browser.
如何在asp.net core 2.0中实现范围请求/响应?
How to implement the range request / response in asp.net core 2.0?
var fileStream = await this.amazonS3Service.Open(
request.FileName,
path,
cancellationToken);
return new FileStreamResult(fileStream, this.GetContentType(request.FileName));
推荐答案
iOS认为是流范围和内容长度标头
What iOS considered to be is stream range and content-length header
在dotnet Core 2.1中添加了对范围的支持
In dotnet Core 2.1 was added support for Ranges
将文件构造函数与enableRangeProcessing一起使用
Use File constructor with enableRangeProcessing
return File(fileStream, this.GetContentType(request.FileName), true);
这篇关于在Asp.NET Core 2.0中的Safari/iOS设备上无法播放视频文件流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!