jellyfin/MediaBrowser.Controller/Resolvers/AudioResolver.cs
LukePulverenti Luke Pulverenti luke pulverenti 82799df9be Made IsAudioFile private
2012-08-11 15:49:58 -04:00

49 lines
1.2 KiB
C#

using System.ComponentModel.Composition;
using System.IO;
using MediaBrowser.Controller.Events;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Resolvers
{
[Export(typeof(IBaseItemResolver))]
public class AudioResolver : BaseItemResolver<Audio>
{
protected override Audio Resolve(ItemResolveEventArgs args)
{
// Return audio if the path is a file and has a matching extension
if (!args.IsFolder)
{
if (IsAudioFile(args.Path))
{
return new Audio();
}
}
return null;
}
private static bool IsAudioFile(string path)
{
string extension = Path.GetExtension(path).ToLower();
switch (extension)
{
case ".mp3":
case ".wma":
case ".acc":
case ".flac":
case ".m4a":
case ".m4b":
case ".wav":
case ".ape":
return true;
default:
return false;
}
}
}
}