Exemple #1
0
        private async Task _ListDevices()
        {
            SnapDotNet.Player.Device[] devices = await SnapDotNet.Player.Player.GetDevicesAsync();

            m_DeviceControls.Clear();
            spDevices.Children.Clear();
            foreach (SnapDotNet.Player.Device device in devices)
            {
                Controls.Device          d   = new Controls.Device(device);
                SnapDotNet.Player.Device dev = device;
                d.State          = m_Player.GetState(dev.UniqueId);
                d.OnPlayClicked += () =>
                {
                    if (d.State == SnapDotNet.Player.EState.Stopped)
                    {
                        Task play = Task.Run(() => m_Player.PlayAsync(dev.UniqueId, dev.Name));
                        play.ConfigureAwait(false);
                    }
                    else
                    {
                        m_Player.Stop(dev.UniqueId);
                    }
                };

                d.OnSettingsClicked += () =>
                {
                    DeviceSettings settings = new DeviceSettings(device);
                    settings.ShowDialog();
                };

                d.OnAutoPlayToggled += (bool autoPlay) =>
                {
                    SnapSettings.SetAudioDeviceAutoPlay(dev.UniqueId, autoPlay, dev.Name);
                };

                bool autoPlay = false;
                if (m_DeviceAutoPlayFlags.ContainsKey(dev.UniqueId))
                {
                    autoPlay = m_DeviceAutoPlayFlags[dev.UniqueId].Item1;
                }
                d.SetAutoPlay(autoPlay);
                spDevices.Children.Add(d);
                m_DeviceControls.Add(dev.UniqueId, d);
            }
        }
Exemple #2
0
        public DeviceSettings(SnapDotNet.Player.Device device)
        {
            InitializeComponent();
            m_Device   = device;
            this.Title = device.Name;
            m_Settings = SnapSettings.GetDeviceSettings(device.UniqueId);

            string[] sharemodes = Enum.GetNames(typeof(SnapDotNet.Player.EShareMode));
            foreach (string mode in sharemodes)
            {
                cbSharemode.Items.Add(mode);
            }

            cbSharemode.SelectedIndex = (int)m_Settings.ShareMode;

            cbSampleFormat.Items.Add("(no resample)");
            cbSampleFormat.SelectedIndex = 0;
            int idx = 1;

            foreach (int sr in kSampleRates)
            {
                foreach (int bp in kBitDepths)
                {
                    string sampleFormat = string.Format("{0}:{1}", sr, bp);
                    cbSampleFormat.Items.Add(sampleFormat);
                    if (m_Settings.ResampleFormat == sampleFormat)
                    {
                        cbSampleFormat.SelectedIndex = idx;
                    }
                    idx++;
                }
            }
            tbHostId.Text                = m_Settings.HostId;
            tbRestartTries.Text          = m_Settings.RestartAttempts.ToString();
            cbAutoRestart.IsChecked      = m_Settings.AutoRestartOnFailure;
            cbUseSnapClientNet.IsChecked = m_Settings.UseSnapClientNet;
        }