Added an audio handler

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-08-10 09:18:30 -04:00
parent 2536011247
commit fbf3916bce
4 changed files with 52 additions and 2 deletions

View File

@ -0,0 +1,45 @@
using System;
using MediaBrowser.Common.Net.Handlers;
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Api.HttpHandlers
{
public class AudioHandler : StaticFileHandler
{
private BaseItem _LibraryItem;
/// <summary>
/// Gets the library item that will be played, if any
/// </summary>
private BaseItem LibraryItem
{
get
{
if (_LibraryItem == null)
{
string id = QueryString["id"];
if (!string.IsNullOrEmpty(id))
{
_LibraryItem = Kernel.Instance.GetItemById(Guid.Parse(id));
}
}
return _LibraryItem;
}
}
public override string Path
{
get
{
if (LibraryItem != null)
{
return LibraryItem.Path;
}
return base.Path;
}
}
}
}

View File

@ -47,6 +47,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="ApiService.cs" /> <Compile Include="ApiService.cs" />
<Compile Include="HttpHandlers\AudioHandler.cs" />
<Compile Include="HttpHandlers\GenreHandler.cs" /> <Compile Include="HttpHandlers\GenreHandler.cs" />
<Compile Include="HttpHandlers\GenresHandler.cs" /> <Compile Include="HttpHandlers\GenresHandler.cs" />
<Compile Include="HttpHandlers\ImageHandler.cs" /> <Compile Include="HttpHandlers\ImageHandler.cs" />

View File

@ -89,6 +89,10 @@ namespace MediaBrowser.Api
{ {
return new StaticFileHandler(); return new StaticFileHandler();
} }
else if (localPath.EndsWith("/api/audio", StringComparison.OrdinalIgnoreCase))
{
return new AudioHandler();
}
return null; return null;
} }

View File

@ -10,7 +10,7 @@ namespace MediaBrowser.Common.Net.Handlers
{ {
public class StaticFileHandler : BaseHandler public class StaticFileHandler : BaseHandler
{ {
public string Path public virtual string Path
{ {
get get
{ {