Skip to content

Commit

Permalink
Version 0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
dsafa committed Aug 22, 2018
2 parents b6fab29 + 924132c commit fbc4e4c
Show file tree
Hide file tree
Showing 26 changed files with 232 additions and 209 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[![Build status](https://ci.appveyor.com/api/projects/status/v32xl29r8uucuwj3?svg=true)](https://ci.appveyor.com/project/dsafa/audio-band)

# Audio Band
*This is still a work in progress!*
*IMPORTANT! Getting song information from spotify is currently unavailable*

Audio Band allows you to display song information in the taskbar.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{30F2BFEA-788A-494D-88E7-F2070528EBEA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>AudioBand.Connector</RootNamespace>
<AssemblyName>AudioBand.Connector</AssemblyName>
<RootNamespace>AudioBand.AudioSource</RootNamespace>
<AssemblyName>AudioBand.AudioSource</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
Expand Down Expand Up @@ -37,9 +37,9 @@
<Reference Include="System.Drawing" />
</ItemGroup>
<ItemGroup>
<Compile Include="IAudioConnector.cs" />
<Compile Include="IConnectorContext.cs" />
<Compile Include="IConnectorLogger.cs" />
<Compile Include="IAudioSource.cs" />
<Compile Include="IAudioSourceContext.cs" />
<Compile Include="IAudioSourceLogger.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="TrackInfoChangedEventArgs.cs" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
using System.Threading;
using System.Threading.Tasks;

namespace AudioBand.Connector
namespace AudioBand.AudioSource
{
[InheritedExport(typeof(IAudioConnector))]
public interface IAudioConnector
/// <summary>
/// Provides information from an audio source and exposes controls
/// </summary>
[InheritedExport(typeof(IAudioSource))]
public interface IAudioSource
{
/// <summary>
/// Name of the connector which is displayed
/// Name of the audio source which is displayed
/// </summary>
string ConnectorName { get; }
string Name { get; }

/// <summary>
/// Track information has changed
Expand All @@ -34,12 +37,12 @@ public interface IAudioConnector
event EventHandler<double> TrackProgressChanged;

/// <summary>
/// Connector is selected as the audio source
/// This audio source has been selected
/// </summary>
Task ActivateAsync(IConnectorContext context, CancellationToken cancellationToken = default(CancellationToken));
Task ActivateAsync(IAudioSourceContext context, CancellationToken cancellationToken = default(CancellationToken));

/// <summary>
/// Connector is no longer the audio source
/// The audio source is no longer active
/// </summary>
Task DeactivateAsync(CancellationToken cancellationToken = default(CancellationToken));

Expand Down
7 changes: 7 additions & 0 deletions src/AudioBand.AudioSource/IAudioSourceContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace AudioBand.AudioSource
{
public interface IAudioSourceContext
{
IAudioSourceLogger Logger { get; }
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace AudioBand.Connector
namespace AudioBand.AudioSource
{
public interface IConnectorLogger
public interface IAudioSourceLogger
{
void Debug(string message);
void Info(string message);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AudioBand.Connector")]
[assembly: AssemblyTitle("AudioBand.AudioSource")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AudioBand.Connector")]
[assembly: AssemblyProduct("AudioBand.AudioSource")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System;
using System.Drawing;

namespace AudioBand.Connector
namespace AudioBand.AudioSource
{
public class TrackInfoChangedEventArgs : EventArgs
{
Expand Down
7 changes: 0 additions & 7 deletions src/AudioBand.Connector/IConnectorContext.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/AudioBand.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ VisualStudioVersion = 15.0.27428.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioBand", "AudioBand\AudioBand.csproj", "{B69832AD-8373-47AC-A52A-183238903896}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioBand.Connector", "AudioBand.Connector\AudioBand.Connector.csproj", "{30F2BFEA-788A-494D-88E7-F2070528EBEA}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AudioBand.AudioSource", "AudioBand.AudioSource\AudioBand.AudioSource.csproj", "{30F2BFEA-788A-494D-88E7-F2070528EBEA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyConnector", "SpotifyConnector\SpotifyConnector.csproj", "{43B57D81-7FAE-40D0-921E-E29F7E848288}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpotifyAudioSource", "SpotifyAudioSource\SpotifyAudioSource.csproj", "{43B57D81-7FAE-40D0-921E-E29F7E848288}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
25 changes: 13 additions & 12 deletions src/AudioBand/AudioBand.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
<AllowedReferenceRelatedFileExtensions>.none</AllowedReferenceRelatedFileExtensions>
</PropertyGroup>
<ItemGroup>
<Reference Include="CSDeskBand, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CSDeskBand.1.0.0\lib\net461\CSDeskBand.dll</HintPath>
<Reference Include="CSDeskBand, Version=2.0.0.0, Culture=neutral, PublicKeyToken=66d19cfc65a1cc19, processorArchitecture=MSIL">
<HintPath>..\packages\CSDeskBand.2.0.0\lib\net461\CSDeskBand.dll</HintPath>
</Reference>
<Reference Include="CSDeskBand.Win, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\CSDeskBand.Win.1.0.0\lib\net461\CSDeskBand.Win.dll</HintPath>
<Reference Include="CSDeskBand.Win, Version=2.0.0.0, Culture=neutral, PublicKeyToken=66d19cfc65a1cc19, processorArchitecture=MSIL">
<HintPath>..\packages\CSDeskBand.Win.2.0.0\lib\net461\CSDeskBand.Win.dll</HintPath>
</Reference>
<Reference Include="MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
<HintPath>..\packages\MetroModernUI.1.4.0.0\lib\net\MetroFramework.dll</HintPath>
Expand All @@ -49,7 +49,7 @@
<HintPath>..\packages\Nett.0.9.0\lib\Net40\Nett.dll</HintPath>
</Reference>
<Reference Include="NLog, Version=4.0.0.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c, processorArchitecture=MSIL">
<HintPath>..\packages\NLog.4.5.4\lib\net45\NLog.dll</HintPath>
<HintPath>..\packages\NLog.4.5.8\lib\net45\NLog.dll</HintPath>
</Reference>
<Reference Include="Svg, Version=2.2.1.39233, Culture=neutral, PublicKeyToken=12a0bac221edeae2, processorArchitecture=MSIL">
<HintPath>..\packages\Svg.2.3.0\lib\net35\Svg.dll</HintPath>
Expand All @@ -72,24 +72,25 @@
<Compile Include="AlbumArtTooltip.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ConnectorContext.cs" />
<Compile Include="ConnectorLogger.cs" />
<Compile Include="Settings\AudioBandAppearance.cs" />
<Compile Include="AudioSourceContext.cs" />
<Compile Include="AudioSourceLogger.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="ViewModels\AudioBandAppearance.cs" />
<Compile Include="DirectoryHelper.cs" />
<Compile Include="MainControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="MainControl.Designer.cs">
<DependentUpon>MainControl.cs</DependentUpon>
</Compile>
<Compile Include="AudioBandViewModel.cs" />
<Compile Include="ViewModels\PlaybackViewModel.cs" />
<Compile Include="EnhancedProgressBar.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="NowPlayingDisplay.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Plugins\ConnectorManager.cs" />
<Compile Include="AudioSource\AudioSourceManager.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
Expand Down Expand Up @@ -132,9 +133,9 @@
<Content Include="Resources\previous.svg" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AudioBand.Connector\AudioBand.Connector.csproj">
<ProjectReference Include="..\AudioBand.AudioSource\AudioBand.AudioSource.csproj">
<Project>{30f2bfea-788a-494d-88e7-f2070528ebea}</Project>
<Name>AudioBand.Connector</Name>
<Name>AudioBand.AudioSource</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
using System;
using AudioBand.Connector;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.IO;
using System.Linq;
using NLog;

namespace AudioBand.Plugins
namespace AudioBand.AudioSource
{
internal class ConnectorManager
internal class AudioSourceManager
{
[ImportMany(AllowRecomposition = true)]
public IEnumerable <IAudioConnector> AudioConnectors { get; private set; }
public IEnumerable <IAudioSource> AudioSources { get; private set; }

public event EventHandler PluginsChanged;
public event EventHandler AudioSourcesChanged;

private const string PluginFolderName = "connectors";
private const string PluginFolderName = "AudioSources";
private AggregateCatalog _catalog;
private CompositionContainer _container;
private List<DirectoryCatalog> _directoryCatalogs;
private FileSystemWatcher _fileSystemWatcher;
private readonly ILogger _logger = LogManager.GetCurrentClassLogger();

public ConnectorManager()
public AudioSourceManager()
{
BuildCatalog();
BuildContainer();
AudioConnectors = _container.GetExportedValues<IAudioConnector>();
AudioSources = _container.GetExportedValues<IAudioSource>();

foreach (var audioSource in AudioSources)
{
_logger.Debug($"Audio source loaded: `{audioSource.Name}`");
}
}

private void BuildCatalog()
{
var basePath = DirectoryHelper.BaseDirectory;
var pluginFolderPath = Path.Combine(basePath, PluginFolderName);
_logger.Debug($"Searching for audio sources in path `{pluginFolderPath}`");

if (!Directory.Exists(pluginFolderPath))
{
Directory.CreateDirectory(pluginFolderPath);
Expand All @@ -40,6 +48,7 @@ private void BuildCatalog()
_directoryCatalogs = Directory.EnumerateDirectories(pluginFolderPath, "*", SearchOption.TopDirectoryOnly)
.Select(d => new DirectoryCatalog(d))
.ToList();
_directoryCatalogs.ForEach(d => _logger.Debug($"Found subfolder {d.Path}"));

_catalog = new AggregateCatalog(_directoryCatalogs);

Expand All @@ -54,13 +63,14 @@ private void BuildCatalog()

private void FileSystemWatcherOnCreated(object sender, FileSystemEventArgs fileSystemEventArgs)
{
_logger.Debug($"Detected new audio source folder `{fileSystemEventArgs.FullPath}");
foreach (var directoryCatalog in _directoryCatalogs)
{
directoryCatalog.Refresh();
}

AudioConnectors = _container.GetExportedValues<IAudioConnector>();
PluginsChanged?.Invoke(this, EventArgs.Empty);
AudioSources = _container.GetExportedValues<IAudioSource>();
AudioSourcesChanged?.Invoke(this, EventArgs.Empty);
}

private void BuildContainer()
Expand Down
14 changes: 14 additions & 0 deletions src/AudioBand/AudioSourceContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using AudioBand.AudioSource;

namespace AudioBand
{
internal class AudioSourceContext : IAudioSourceContext
{
public IAudioSourceLogger Logger { get; }

public AudioSourceContext(string audioSourceName)
{
Logger = new AudioSourceLogger(audioSourceName);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
using AudioBand.Connector;
using AudioBand.AudioSource;
using NLog;

namespace AudioBand
{
internal class ConnectorLogger : IConnectorLogger
internal class AudioSourceLogger : IAudioSourceLogger
{
private readonly ILogger _logger;

public ConnectorLogger(string name)
public AudioSourceLogger(string name)
{
_logger = LogManager.GetLogger("Connector:" + name);
_logger = LogManager.GetLogger("AudioSource:" + name);
}

public void Debug(string message)
Expand Down
14 changes: 0 additions & 14 deletions src/AudioBand/ConnectorContext.cs

This file was deleted.

22 changes: 22 additions & 0 deletions src/AudioBand/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using Svg;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace AudioBand
{
internal static class Extensions
{
public static Bitmap ToBitmap(this SvgDocument svg)
{
var bmp = new Bitmap((int)svg.Width.Value, (int)svg.Height.Value);
using (var graphics = Graphics.FromImage(bmp))
{
graphics.SmoothingMode = SmoothingMode.AntiAlias;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.InterpolationMode = InterpolationMode.High;
svg.Draw(graphics);
return bmp;
}
}
}
}
Loading

0 comments on commit fbc4e4c

Please sign in to comment.