jellyfin/MediaBrowser.Controller/Resolvers/AudioResolver.cs

55 lines
1.4 KiB
C#
Raw Normal View History

2012-09-09 15:15:22 +00:00
using MediaBrowser.Controller.Library;
2012-07-12 06:55:27 +00:00
using MediaBrowser.Model.Entities;
2012-09-09 15:15:22 +00:00
using System.ComponentModel.Composition;
using System.IO;
2012-07-12 06:55:27 +00:00
namespace MediaBrowser.Controller.Resolvers
{
[Export(typeof(IBaseItemResolver))]
2012-07-12 06:55:27 +00:00
public class AudioResolver : BaseItemResolver<Audio>
{
public override ResolverPriority Priority
{
get { return ResolverPriority.Last; }
}
2012-07-12 06:55:27 +00:00
protected override Audio Resolve(ItemResolveEventArgs args)
{
// Return audio if the path is a file and has a matching extension
2012-08-21 14:42:40 +00:00
if (!args.IsDirectory)
2012-07-12 06:55:27 +00:00
{
if (IsAudioFile(args.Path))
{
return new Audio();
}
}
return null;
}
2012-08-11 19:49:58 +00:00
private static bool IsAudioFile(string path)
2012-07-12 06:55:27 +00:00
{
string extension = Path.GetExtension(path).ToLower();
switch (extension)
{
case ".mp3":
case ".wma":
2012-09-09 14:03:49 +00:00
case ".aac":
2012-07-12 06:55:27 +00:00
case ".acc":
case ".flac":
case ".m4a":
case ".m4b":
case ".wav":
case ".ape":
return true;
default:
return false;
}
}
}
}