Skip to content

Commit

Permalink
added test conosle application.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfryer committed Apr 9, 2015
1 parent b4b2c61 commit 64599c9
Show file tree
Hide file tree
Showing 5 changed files with 243 additions and 0 deletions.
131 changes: 131 additions & 0 deletions SimpleSonos.ConsoleTest/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using DiscoverTest;

namespace SimpleSonos.ConsoleTest
{
internal class Program
{
private static void Main(string[] args)
{
var sonosController = new SonosController();

sonosController.IndexingStarted += OnIndexingStarted;
//sonosController.DeviceFound += OnDeviceFound;
sonosController.IndexingEnded += OnIndexingEnded;
sonosController.RoomFound += sonosController_RoomFound;

sonosController.IndexRooms();

DoWork(sonosController);

var key = Console.ReadKey();
}

private static async Task DoWork(SonosController sonosController)
{
foreach (var room in sonosController.Rooms)
{
if (room.Name == "Office")
{
await room.SetVolumeAsync(40);
//while (true)
//{
await room.PauseAsync();
Thread.Sleep(1000);
await room.PlayAsync();
Thread.Sleep(1000);
//}
}
}
}


private static void sonosController_RoomFound(IRoom room)
{
room.DeviceAdded += room_DeviceAdded;
room.VolumeChanged += room_VolumeChanged;
room.Muted += room_Muted;
room.Unmuted += room_Unmuted;

room.Stopped += room_Stopped;
room.Transitioning += room_Transitioning;
room.Playing += room_Playing;


Console.WriteLine("ROOM FOUND: " + room.Name);
}

private static void room_Playing(IRoom room)
{
Console.WriteLine("ROOM PLAYING: " + room.Name);
}

private static void room_Transitioning(IRoom room)
{
Console.WriteLine("ROOM TRANSITIONING: " + room.Name);
}

private static void room_Stopped(IRoom room)
{
Console.WriteLine("ROOM STOPPED: " + room.Name);
}

private static void room_Unmuted(IRoom room)
{
Console.WriteLine("ROOM Unmuted: " + room.Name);
}

private static void room_Muted(IRoom room)
{
Console.WriteLine("ROOM Muted: " + room.Name);
}

private static void room_VolumeChanged(IRoom room, int level)
{
Console.WriteLine("VOLUME CHANGE ROOM: " + room.Name + ", LEVEL: " + level);
}

private static void room_DeviceAdded(IRoom room, IDevice device)
{
device.TrackUpdate += device_TrackUpdate;
// device.VolumeChanged += OnDeviceVolumeChanged;
//device.Muted += OnDeviceMuted;
//device.Unmuted += OnDeviceUnmuted;
//Console.WriteLine("DEVICE FOUND. Room: " + room.Name + ", Type: " + device.GetType().Name);
}

private static void device_TrackUpdate(IDevice sonosDevice, MusicTrack args)
{
Console.WriteLine("Device: " + sonosDevice.IpAddress + ", Track Update: " + args.Title + ", Album: " +
args.Album.Name + ", Artist: " + args.Creator);
}


private static void OnIndexingStarted(object s, EventArgs a)
{
Console.WriteLine("Indexing Started");
}

private static void OnIndexingEnded(object s, EventArgs a)
{
Console.WriteLine("Finished Indexing");
}

private static void OnDeviceVolumeChanged(Device device, int args)
{
Console.WriteLine(device.IpAddress + " Volume Changed: " + args);
}

private static void OnDeviceUnmuted(Device device)
{
Console.WriteLine("Device Unmuted, " + device.IpAddress);
}

private static void OnDeviceMuted(Device device)
{
Console.WriteLine("Device Muted, " + device.IpAddress);
}
}
}
36 changes: 36 additions & 0 deletions SimpleSonos.ConsoleTest/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// 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("SimpleSonos.ConsoleTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SimpleSonos.ConsoleTest")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8c612827-e65c-4ca8-82c7-942ddb98a4b5")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
67 changes: 67 additions & 0 deletions SimpleSonos.ConsoleTest/SimpleSonos.ConsoleTest.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C3680770-5F56-4E00-B8F9-444669A2AAAF}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SimpleSonos.ConsoleTest</RootNamespace>
<AssemblyName>SimpleSonos.ConsoleTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\SimpleSonos\SimpleSonos.csproj">
<Project>{BF8524BA-DC49-4A99-A040-5E2CF37CC8FD}</Project>
<Name>SimpleSonos</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
3 changes: 3 additions & 0 deletions SimpleSonos.ConsoleTest/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
6 changes: 6 additions & 0 deletions SimpleSonos/SimpleSonos.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleSonos", "SimpleSonos.csproj", "{BF8524BA-DC49-4A99-A040-5E2CF37CC8FD}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleSonos.ConsoleTest", "..\SimpleSonos.ConsoleTest\SimpleSonos.ConsoleTest.csproj", "{C3680770-5F56-4E00-B8F9-444669A2AAAF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{BF8524BA-DC49-4A99-A040-5E2CF37CC8FD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BF8524BA-DC49-4A99-A040-5E2CF37CC8FD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BF8524BA-DC49-4A99-A040-5E2CF37CC8FD}.Release|Any CPU.Build.0 = Release|Any CPU
{C3680770-5F56-4E00-B8F9-444669A2AAAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C3680770-5F56-4E00-B8F9-444669A2AAAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C3680770-5F56-4E00-B8F9-444669A2AAAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C3680770-5F56-4E00-B8F9-444669A2AAAF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down

0 comments on commit 64599c9

Please sign in to comment.