The Free Software Media System - Server Backend & API
Added an audio handler
LukePulverenti Luke Pulverenti luke pulverentifbf3916bcec3
diff --git a/MediaBrowser.Api/HttpHandlers/AudioHandler.cs b/MediaBrowser.Api/HttpHandlers/AudioHandler.csnew file mode 100644index 0000000000..8ebaf04bcd--- /dev/null+++ b/MediaBrowser.Api/HttpHandlers/AudioHandler.cs@@ -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;+ }+ }+ }+}diff --git a/MediaBrowser.Api/MediaBrowser.Api.csproj b/MediaBrowser.Api/MediaBrowser.Api.csprojindex 4560f70a15..33c209cd43 100644--- a/MediaBrowser.Api/MediaBrowser.Api.csproj+++ b/MediaBrowser.Api/MediaBrowser.Api.csproj@@ -47,6 +47,7 @@</ItemGroup><ItemGroup><Compile Include="ApiService.cs" />+ <Compile Include="HttpHandlers\AudioHandler.cs" /><Compile Include="HttpHandlers\GenreHandler.cs" /><Compile Include="HttpHandlers\GenresHandler.cs" /><Compile Include="HttpHandlers\ImageHandler.cs" />diff --git a/MediaBrowser.Api/Plugin.cs b/MediaBrowser.Api/Plugin.csindex fe061a48b0..02546c6936 100644--- a/MediaBrowser.Api/Plugin.cs+++ b/MediaBrowser.Api/Plugin.cs@@ -44,7 +44,7 @@ namespace MediaBrowser.Apielse if (localPath.EndsWith("/api/image", StringComparison.OrdinalIgnoreCase)){return new ImageHandler();- }+ }else if (localPath.EndsWith("/api/users", StringComparison.OrdinalIgnoreCase)){return new UsersHandler();@@ -89,6 +89,10 @@ namespace MediaBrowser.Api{return new StaticFileHandler();}+ else if (localPath.EndsWith("/api/audio", StringComparison.OrdinalIgnoreCase))+ {+ return new AudioHandler();+ }return null;}diff --git a/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs b/MediaBrowser.Common/Net/Handlers/StaticFileHandler.csindex 9c99121529..9bffd8e597 100644--- a/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs+++ b/MediaBrowser.Common/Net/Handlers/StaticFileHandler.cs@@ -10,7 +10,7 @@ namespace MediaBrowser.Common.Net.Handlers{public class StaticFileHandler : BaseHandler{- public string Path+ public virtual string Path{get{