-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
243 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters