Added mp3 streaming for songs and a player to the app (experimental)
This commit is contained in:
1 parent
18bdb7aa05
commit
1e71360366
7 files changed
+52
-2
No files matched your search
@@ -37,7 +37,8 @@ namespace ServerLib
|
||||
{
|
||||
sessionKey = Guid.Parse(sessionHeader);
|
||||
}
|
||||
catch (Exception) {}
|
||||
catch (Exception)
|
||||
{ }
|
||||
return sessionKey;
|
||||
}
|
||||
|
||||
@@ -144,7 +145,7 @@ namespace ServerLib
|
||||
public SProfileData[] GetProfileList()
|
||||
{
|
||||
if (CServer.GetProfileList == null)
|
||||
return new SProfileData[] {};
|
||||
return new SProfileData[] { };
|
||||
return CServer.GetProfileList();
|
||||
}
|
||||
#endregion
|
||||
@@ -308,6 +309,32 @@ namespace ServerLib
|
||||
{
|
||||
return CServer.GetAllSongs();
|
||||
}
|
||||
|
||||
public Stream GetMp3File(int songId)
|
||||
{
|
||||
if (WebOperationContext.Current != null)
|
||||
{
|
||||
WebOperationContext.Current.OutgoingResponse.ContentType = "audio/mpeg";
|
||||
WebOperationContext.Current.OutgoingResponse.LastModified = DateTime.UtcNow;
|
||||
WebOperationContext.Current.OutgoingResponse.Headers.Add(
|
||||
HttpResponseHeader.Expires,
|
||||
DateTime.UtcNow.AddYears(1).ToString("r"));
|
||||
}
|
||||
|
||||
|
||||
String path = CServer.GetMp3Path(songId);
|
||||
path = path.Replace("..", "");
|
||||
|
||||
|
||||
if (!File.Exists(path) || !(path.EndsWith(".mp3", StringComparison.InvariantCulture) || path.EndsWith(".ogg", StringComparison.InvariantCulture)))
|
||||
{
|
||||
if (WebOperationContext.Current != null)
|
||||
WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotFound;
|
||||
return null;
|
||||
}
|
||||
|
||||
return File.OpenRead(path);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region playlist
|
||||
|
||||
Reference in new issue
Block a user