[Server] More audio formats for streaming
This commit is contained in:
1 parent
e4ce006b06
commit
7db3b0f9f9
1 file changed
+25
-2
@@ -322,7 +322,6 @@ namespace ServerLib
|
|||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
{
|
{
|
||||||
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/mpeg";
|
|
||||||
WebOperationContext.Current.OutgoingResponse.LastModified = DateTime.UtcNow;
|
WebOperationContext.Current.OutgoingResponse.LastModified = DateTime.UtcNow;
|
||||||
WebOperationContext.Current.OutgoingResponse.Headers.Add(
|
WebOperationContext.Current.OutgoingResponse.Headers.Add(
|
||||||
HttpResponseHeader.Expires,
|
HttpResponseHeader.Expires,
|
||||||
@@ -334,13 +333,37 @@ namespace ServerLib
|
|||||||
path = path.Replace("..", "");
|
path = path.Replace("..", "");
|
||||||
|
|
||||||
|
|
||||||
if (!File.Exists(path) || !(path.EndsWith(".mp3", StringComparison.InvariantCulture) || path.EndsWith(".ogg", StringComparison.InvariantCulture)))
|
if (!File.Exists(path)
|
||||||
|
|| !(path.EndsWith(".mp3", StringComparison.InvariantCulture)
|
||||||
|
|| path.EndsWith(".ogg", StringComparison.InvariantCulture)
|
||||||
|
|| path.EndsWith(".wav", StringComparison.InvariantCulture)
|
||||||
|
|| path.EndsWith(".webm", StringComparison.InvariantCulture)))
|
||||||
{
|
{
|
||||||
if (WebOperationContext.Current != null)
|
if (WebOperationContext.Current != null)
|
||||||
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (WebOperationContext.Current != null)
|
||||||
|
{
|
||||||
|
if (path.EndsWith(".mp3", StringComparison.InvariantCulture))
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/mpeg";
|
||||||
|
}
|
||||||
|
else if (path.EndsWith(".ogg", StringComparison.InvariantCulture))
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/ogg";
|
||||||
|
}
|
||||||
|
else if (path.EndsWith(".wav", StringComparison.InvariantCulture))
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/wav";
|
||||||
|
}
|
||||||
|
else if (path.EndsWith(".webm", StringComparison.InvariantCulture))
|
||||||
|
{
|
||||||
|
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/webm";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return File.OpenRead(path);
|
return File.OpenRead(path);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
Reference in new issue
Block a user