2013-04-27 17:44:38 -07:00
|
|
|
|
using MediaBrowser.Controller.Library;
|
|
|
|
|
using MediaBrowser.Controller.Resolvers;
|
2014-02-23 13:35:58 -07:00
|
|
|
|
using MediaBrowser.Model.Entities;
|
|
|
|
|
using System;
|
2013-03-02 23:58:04 -07:00
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Class AudioResolver
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class AudioResolver : ItemResolver<Controller.Entities.Audio.Audio>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the priority.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>The priority.</value>
|
|
|
|
|
public override ResolverPriority Priority
|
|
|
|
|
{
|
|
|
|
|
get { return ResolverPriority.Last; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Resolves the specified args.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="args">The args.</param>
|
|
|
|
|
/// <returns>Entities.Audio.Audio.</returns>
|
|
|
|
|
protected override Controller.Entities.Audio.Audio Resolve(ItemResolveArgs args)
|
|
|
|
|
{
|
|
|
|
|
// Return audio if the path is a file and has a matching extension
|
|
|
|
|
|
|
|
|
|
if (!args.IsDirectory)
|
|
|
|
|
{
|
2013-04-28 07:18:17 -07:00
|
|
|
|
if (EntityResolutionHelper.IsAudioFile(args.Path))
|
2013-03-02 23:58:04 -07:00
|
|
|
|
{
|
2014-02-23 13:35:58 -07:00
|
|
|
|
var collectionType = args.GetCollectionType();
|
|
|
|
|
|
2014-04-14 20:54:52 -07:00
|
|
|
|
var isStandalone = args.Parent == null;
|
|
|
|
|
|
|
|
|
|
if (isStandalone ||
|
2014-04-19 10:43:12 -07:00
|
|
|
|
string.Equals(collectionType, CollectionType.Music, StringComparison.OrdinalIgnoreCase) ||
|
|
|
|
|
string.IsNullOrEmpty(collectionType))
|
2014-02-23 13:35:58 -07:00
|
|
|
|
{
|
|
|
|
|
return new Controller.Entities.Audio.Audio();
|
|
|
|
|
}
|
2013-03-02 23:58:04 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|