Пример #1
0
        /// <summary>
        /// Called when the PlaybackDeviceAvailableMessage message is received
        /// If this is a change then report it
        /// </summary>
        /// <param name="message"></param>
        private static void DeviceAvailable(PlaybackDevice newDevice)
        {
            PlaybackDevice oldDevice = PlaybackManagerModel.AvailableDevice;

            // Check for no new device
            if (newDevice == null)
            {
                // If there was an exisiting availabel device then repoprt this change
                if (oldDevice != null)
                {
                    PlaybackManagerModel.AvailableDevice = null;
                    DataReporter?.SelectPlaybackDevice(oldDevice);
                }
            }
            // If there was no available device then save the new device and report the change
            else if (oldDevice == null)
            {
                PlaybackManagerModel.AvailableDevice = newDevice;
                DataReporter?.SelectPlaybackDevice(oldDevice);
            }
            // If the old and new are different type (local/remote) then report the change
            else if (oldDevice.IsLocal != newDevice.IsLocal)
            {
                PlaybackManagerModel.AvailableDevice = newDevice;
                DataReporter?.SelectPlaybackDevice(oldDevice);
            }
            // If both devices are remote but different then report the change
            else if ((oldDevice.IsLocal == false) && (newDevice.IsLocal == false) && (oldDevice.FriendlyName != newDevice.FriendlyName))
            {
                PlaybackManagerModel.AvailableDevice = newDevice;
                DataReporter?.SelectPlaybackDevice(oldDevice);
            }
        }