public async System.Threading.Tasks.Task CreateAudioGraphAsync(string outputFileName) { Windows.Media.Audio.AudioGraphSettings graphSettings = new Windows.Media.Audio.AudioGraphSettings(Windows.Media.Render.AudioRenderCategory.Media); graphSettings.QuantumSizeSelectionMode = Windows.Media.Audio.QuantumSizeSelectionMode.LowestLatency; // TODO: let user pick from list of devices instead of blindly picking first one -- hoping for the microphone. Windows.Devices.Enumeration.DeviceInformationCollection deviceInformationCollection = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.Enumeration.DeviceClass.AudioRender); Windows.Devices.Enumeration.DeviceInformation deviceInformation = deviceInformationCollection[0]; // blindly pick first one graphSettings.PrimaryRenderDevice = deviceInformation; Windows.Media.Audio.CreateAudioGraphResult result = await Windows.Media.Audio.AudioGraph.CreateAsync(graphSettings); if (result.Status != Windows.Media.Audio.AudioGraphCreationStatus.Success) { WoundifyShared.Log.WriteLine("Cannot create graph:" + result.Status.ToString()); return; } graph = result.Graph; await AudioDeviceInputAsync(); // setup microphone (usually) //await AudioDeviceOutputAsync(); // setup speakers (usually) await AudioFileOutputAsync(WoundifyShared.Options.options.tempFolderPath + outputFileName); // setup file deviceInputNode.AddOutgoingConnection(fileOutputNode); }
//</SnippetCreateDeviceOutputNode> private async Task EnumerateAudioCaptureDevices() { //<SnippetEnumerateAudioCaptureDevices> Windows.Devices.Enumeration.DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Media.Devices.MediaDevice.GetAudioCaptureSelector()); // Show UI to allow the user to select a device Windows.Devices.Enumeration.DeviceInformation selectedDevice = ShowMyDeviceSelectionUI(devices); CreateAudioDeviceInputNodeResult result = await audioGraph.CreateDeviceInputNodeAsync(Windows.Media.Capture.MediaCategory.Media, audioGraph.EncodingProperties, selectedDevice); //</SnippetEnumerateAudioCaptureDevices> }
//</SnippetInitAudioGraph> private async Task EnumerateAudioRenderDevices() { AudioGraphSettings settings = new AudioGraphSettings(Windows.Media.Render.AudioRenderCategory.Media); //<SnippetEnumerateAudioRenderDevices> Windows.Devices.Enumeration.DeviceInformationCollection devices = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Media.Devices.MediaDevice.GetAudioRenderSelector()); // Show UI to allow the user to select a device Windows.Devices.Enumeration.DeviceInformation selectedDevice = ShowMyDeviceSelectionUI(devices); settings.PrimaryRenderDevice = selectedDevice; //</SnippetEnumerateAudioRenderDevices> }
private Windows.Devices.Enumeration.DeviceInformation ShowMyDeviceSelectionUI(Windows.Devices.Enumeration.DeviceInformationCollection devices) { return(devices[0]); }
private async Task <Tuple <bool, string> > InitializeScannerAsync() { try { var x = await WriteProfile.Write("HoneywellDecoderSettingsV2.exm"); if (App.scanner == null) { App.scanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync(); if (App.scanner == null) { Windows.Devices.Enumeration.DeviceInformationCollection deviceCollection = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.PointOfService.BarcodeScanner.GetDeviceSelector()); if (deviceCollection != null && deviceCollection.Count > 0) { scannerInitComplete = false; foreach (Windows.Devices.Enumeration.DeviceInformation D in deviceCollection) { if (D.Id.Contains("POSBarcodeScanner")) { App.scanner = await Windows.Devices.PointOfService.BarcodeScanner.FromIdAsync(D.Id); } } } } } if (App.scanner != null) { App.claimedScanner = await App.scanner.ClaimScannerAsync(); } if (App.claimedScanner != null) { App.claimedScanner.DataReceived += ClaimedScanner_DataReceivedAsync; App.claimedScanner.ReleaseDeviceRequested += OnClaimedScannerReleaseDeviceRequested; App.claimedScanner.IsDecodeDataEnabled = true; await App.claimedScanner.EnableAsync(); //await obj.claimedScanner.SetActiveSymbologiesAsync(new List<uint> { 0 }); foreach (string ProfileName in App.scanner.GetSupportedProfiles()) { if (ProfileName == "Develok Profile") { await App.claimedScanner.SetActiveProfileAsync(ProfileName); break; } } scannerInitComplete = true; MessagingCenter.Send <xx.App, string>((xx.App)obj.xxApp, "scannerInitStatus", "true"); return(new Tuple <bool, string>(true, null)); } else { return(new Tuple <bool, string>(false, "InitializeScannerAsync 1")); } } catch (Exception ex) { //MessagingCenter.Send<xx.App, string>((xx.App)obj.xxApp, "exception", "ScrannerInit/InitializeScannerAsync: " + ex.Message); return(new Tuple <bool, string>(false, "InitializeScannerAsync " + ex.Message)); } }
private async Task <Tuple <bool, string> > InitializeScannerAsync() { try { //var wp = new xx.UWP.WriteProfile(); //var x = await wp.Write(ProfileFileName); if (scanner == null) { scanner = await Windows.Devices.PointOfService.BarcodeScanner.GetDefaultAsync(); if (scanner == null) { Windows.Devices.Enumeration.DeviceInformationCollection deviceCollection = await Windows.Devices.Enumeration.DeviceInformation.FindAllAsync(Windows.Devices.PointOfService.BarcodeScanner.GetDeviceSelector()); if (deviceCollection != null && deviceCollection.Count > 0) { scannerInitComplete = false; foreach (Windows.Devices.Enumeration.DeviceInformation D in deviceCollection) { if (D.Id.Contains("POSBarcodeScanner")) { scanner = await Windows.Devices.PointOfService.BarcodeScanner.FromIdAsync(D.Id); } } } } } if (scanner != null) { claimedScanner = await scanner.ClaimScannerAsync(); } if (claimedScanner != null) { claimedScanner.DataReceived += ClaimedScanner_DataReceivedAsync; claimedScanner.ReleaseDeviceRequested += OnClaimedScannerReleaseDeviceRequested; claimedScanner.IsDecodeDataEnabled = true; await claimedScanner.EnableAsync(); //await obj.claimedScanner.SetActiveSymbologiesAsync(new List<uint> { 0 }); foreach (string ProfileName in scanner.GetSupportedProfiles()) { if (ProfileName == "Develok Profile") { await claimedScanner.SetActiveProfileAsync(ProfileName); break; } } scannerInitComplete = true; //mp.BtnSettingsBackground(new SolidColorBrush(Color.FromArgb(120, 0, 255, 0))); //if (!mp.skipUpdate) //{ // mp.successOfScanner = true; // if (mp.lstLocalScannerSettings.First().restAddress == "olemas") // { // if (await mp.DisplayMessageYesNoAsync("Serveri aadress on seadistamata. Kas soovid seda teha?")) // { // mp.PrepareSettings(); // } // } // else // { // CheckNewVersionAvailabilityAsync.Check(mp); // mp.TxtBkScannedValue.Focus(FocusState.Programmatic); // } //} return(new Tuple <bool, string>(true, null)); } else { //mp.BtnSettingsBackground(new SolidColorBrush(Colors.Red)); return(new Tuple <bool, string>(false, "InitializeScannerAsync 1")); } } catch (Exception ex) { return(new Tuple <bool, string>(false, "InitializeScannerAsync " + ex.Message)); //mp.SendDebugErrorMessage(this.GetType().Name, "InitializeScannerAsync", ex); } }