Stream video content through Web API 2
Two things:
Use a video element in your HTML (this works in browsers AND iOS):
<video src="http://yoursite.com/api/Media/GetVideo?videoId=42" />
Support
206 PARTIAL CONTENT
requests in you Web API code. This is crucial for both streaming and iOS support, and is mentioned in that thread you posted.
Just follow this example:
https://devblogs.microsoft.com/aspnet/asp-net-web-api-and-http-byte-range-support/
In a nutshell:
if (Request.Headers.Range != null)
{
// Return part of the video
HttpResponseMessage partialResponse = Request.CreateResponse(HttpStatusCode.PartialContent);
partialResponse.Content = new ByteRangeStreamContent(stream, Request.Headers.Range, mediaType);
return partialResponse;
}
else
{
// Return complete video
HttpResponseMessage fullResponse = Request.CreateResponse(HttpStatusCode.OK);
fullResponse.Content = new StreamContent(stream);
fullResponse.Content.Headers.ContentType = mediaType;
return fullResponse;
}