private void InitDeviceList() { SelectedDevInfo selectedDevInfo = _nemo.GetSelectedDevInfo(); _deviceInfoList.Clear(); foreach (var item in _nemo.GetCameraDevices()) { SettingsDeviceInfo info = new SettingsDeviceInfo(); info.NemoDevInfoConverter(item, MediaDeviceType.Camera, 0 == string.CompareOrdinal(selectedDevInfo.CameraDevId, item.devId), 0 == string.CompareOrdinal(selectedDevInfo.SecondCameraDevId, item.devId)); SettingsDeviceListItemInfo itemDev = new SettingsDeviceListItemInfo(info); _deviceInfoList.Add(itemDev); } InitCameraDeviceList(_deviceInfoList); ThreadPool.QueueUserWorkItem(delegate { SynchronizationContext.SetSynchronizationContext(new DispatcherSynchronizationContext(Application.Current.Dispatcher)); SynchronizationContext.Current.Post(pl => { PopMessage = "正在加载设备列表,轻稍后"; PopVisibility = Visibility.Visible; InitMicrophoneDeviceList(_nemo.GetMicrophoneDevices(), selectedDevInfo.MicrophoneDevId); InitSpeakerDeviceList(_nemo.GetSpeakerDevices(), selectedDevInfo.SpeakerDevId); PopVisibility = Visibility.Collapsed; }, null); }); }
/// <summary> /// 初始化麦克风设备列表 /// </summary> /// <param name="devInfos"></param> /// <param name="selectedDevId"></param> private void InitMicrophoneDeviceList(SDKMediaDevInfo[] devInfos, string selectedDevId) { if (0 >= devInfos.Length) { return; } foreach (SDKMediaDevInfo devInfo in devInfos) { SettingsDeviceInfo info = new SettingsDeviceInfo(); if (0 == string.CompareOrdinal(selectedDevId, devInfo.devId)) { info.NemoDevInfoConverter(devInfo, MediaDeviceType.Microphone, true); } else { info.NemoDevInfoConverter(devInfo, MediaDeviceType.Microphone, false); } SettingsDeviceListItemInfo itemDev = new SettingsDeviceListItemInfo(info); DeviceMicrophoneList.Add(itemDev); } DeviceMicrophoneList = new ObservableCollection <SettingsDeviceListItemInfo>(DeviceMicrophoneList.OrderBy(x => x.DevName).ToList()); }