Example #1
0
        public override async Task <bool> Start()
        {
            var ip = String.Empty;

            if (_useFixedIp.HasValue && _useFixedIp.Value)
            {
                ip = _ip;
            }
            else
            {
                var scan = await SonosDiscovery.DiscoverSonos();

                if (scan.Count == 0)
                {
                    DriverContext.Logger.LogError($"Could not find any sonos device..");
                    return(false);
                }

                var device = scan.FirstOrDefault(a => a.Uuid == _id);

                if (device == null)
                {
                    DriverContext.Logger.LogError($"Could not find sonos device with id {_id}..");
                    return(false);
                }

                ip = device.Location.Host;
            }

            _controller = _sonosControllerFactory.Create(ip);
            return(await base.Start());
        }
Example #2
0
        private static async Task Main(string[] args)
        {
            Log.Logger = new LoggerConfiguration()
                         .WriteTo.Console(theme: AnsiConsoleTheme.Code)
                         .MinimumLevel.Information()
                         .CreateLogger();

            Log.Verbose("Serilog configured...");

            //var container = new WindsorContainer();
            //HardwareRegistrations(container);
            //container.Register(Component.For<BoxBaseOptions>()
            //    .Instance(new BoxBaseOptions
            //    {
            //        IdleTimeout = TimeSpan.FromSeconds(30)
            //    }));

            //box = container.Resolve<IBox>();

            //await box.BlinkAll(2);

            var davin = "192.168.10.219";
            var buro  = "192.168.10.90";

            controller = new SonosControllerFactory().Create(buro);

            var browseResponse = await controller.GetQueueAsync();

            var isPlayingAsync = await controller.GetIsPlayingAsync();

            await controller.PlayAsync();
        }
Example #3
0
        public void SetUp()
        {
            _renderingControlService = new RenderingControlService(TestSpeaker.IpAddress);
            _contentDirectoryService = new ContentDirectoryService(TestSpeaker.IpAddress);

            _sonosController = new SonosController(new AvTransportService(TestSpeaker.IpAddress),
                                                   _renderingControlService,
                                                   _contentDirectoryService);

            _sut = new AvTransportService(TestSpeaker.IpAddress);
        }
Example #4
0
        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();
        }
Example #5
0
        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);
                    //}
                }
            }
        }