You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
jellyfin/MediaBrowser.Controller/Resolvers/AudioResolver.cs

54 lines
1.3 KiB

using System.ComponentModel.Composition;
using System.IO;
using MediaBrowser.Controller.Library;
13 years ago
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Resolvers
{
[Export(typeof(IBaseItemResolver))]
13 years ago
public class AudioResolver : BaseItemResolver<Audio>
{
public override ResolverPriority Priority
{
get { return ResolverPriority.Last; }
}
13 years ago
protected override Audio Resolve(ItemResolveEventArgs args)
{
// Return audio if the path is a file and has a matching extension
if (!args.IsDirectory)
13 years ago
{
if (IsAudioFile(args.Path))
{
return new Audio();
}
}
return null;
}
private static bool IsAudioFile(string path)
13 years ago
{
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;
}
}
}
}