Я пытаюсь воспроизвести видеофайл, который отправляется клиенту в виде байтового массива.Он работает на Android и ПК, но не на устройствах Apple.
Я уже пытался добавить заголовок диапазона содержимого (не совсем уверен, верно ли это), но это тоже не помогло.
загрузка / сохранение файла
var file = await RegisterFileAsync(formFile, uploaderId, categories, packages);
try
{
var filePath = FileStorePath + file.Id;
if (formFile.Length > 0)
{
using (var stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create))
{
await formFile.CopyToAsync(stream);
}
}
if (!System.IO.File.Exists(filePath))
{
throw new System.IO.FileNotFoundException($"File not found ({filePath}) trying to register a file in the database.");
}
}
catch
{
await UnregisterFileAsync(file.Id);
}
return file;
Выглядит так: ![enter image description here](https://i.stack.imgur.com/l37wH.png)
Бэкэнд, отправка файла клиенту:
[HttpHead("[controller]/[action]/{id}")]
[HttpGet("[controller]/[action]/{id}"), HttpGet("[controller]/{id}", Order = 1)]
public async Task<IActionResult> Index(Guid? id)
{
if (id == null)
{
return View();
}
var file = await fileService.GetFileById(id.Value, loadContent: true);
if (file.ContentType.Equals("video/mp4"))
{
Response.Headers.Add("Content-Range", "bytes 0-" + (file.Size - 1) + "/" + file.Size);
}
return File(file.Content, file.ContentType);
}
Заголовки ответа
![enter image description here](https://i.stack.imgur.com/WxlN3.png)
HTML видеоплеер
![enter image description here](https://i.stack.imgur.com/TyOOj.png)