[Server] More audio formats for streaming

This commit is contained in:
lukeIam committed 2014-12-30 15:52:15 +01:00
1 parent e4ce006b06
commit 7db3b0f9f9
1 file changed
+25 -2
+25 -2
View File
@@ -322,7 +322,6 @@ namespace ServerLib
{
if (WebOperationContext.Current != null)
{
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/mpeg";
WebOperationContext.Current.OutgoingResponse.LastModified = DateTime.UtcNow;
WebOperationContext.Current.OutgoingResponse.Headers.Add(
HttpResponseHeader.Expires,
@@ -334,13 +333,37 @@ namespace ServerLib
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)
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
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);
}
#endregion