我正在尝试保存device information
在我的应用程序中。当应用程序启动时,我设法保存as string
到ApplicationData.Current.RoamingSettings
但无法保存到deviceinformation
我需要用来枚举我的设备的位置。
我不确定这样做的正确方法是什么。有人可以建议吗?谢谢。
const string MicDeviceNameKey = "MicDeviceName";
const string MicDeviceIDKey = "MicDeviceID";
IPropertySet settings = ApplicationData.Current.RoamingSettings.Values;
public string MicDeviceName
{
get
{
object setting;
if (settings.TryGetValue(MicDeviceNameKey, out setting))
return (string)setting;
return null;
}
set
{
settings[MicDeviceNameKey] = value;
}
}
public DeviceInformation MicDeviceID
{
get
{
if (settings[MicDeviceIDKey] != null)
return (DeviceInformation)settings[MicDeviceIDKey];
return null;
}
set
{
settings[MicDeviceIDKey] = value;
}
}
更新
我正在使用AudioGraph
将麦克风输入路由到线路输出。有没有办法解决我可以加载保存Device Information
和Capture
设备Render
初始化的地方AudioGraphSettings
。
public async Task CreateMicRoute(DeviceInformation output, DeviceInformation input)
{
// ################################################################################################
// Register the Output Source for the Playback
var settings = new AudioGraphSettings(AudioRenderCategory.Media);
settings.QuantumSizeSelectionMode = QuantumSizeSelectionMode.LowestLatency;
settings.PrimaryRenderDevice = output;
var result = await AudioGraph.CreateAsync(settings);
if (result.Status != AudioGraphCreationStatus.Success)
{
// Cannot create graph
//rootPage.NotifyUser(String.Format("AudioGraph Creation Error because {0}", result.Status.ToString()), NotifyType.ErrorMessage);
return;
}
//Create Audio Graph
micAudioGraph = result.Graph;
// ################################################################################################
// Create a device input node
var inProfile = MediaEncodingProfile.CreateWav(AudioEncodingQuality.Medium);
var DeviceInputResult = await micAudioGraph.CreateDeviceInputNodeAsync(MediaCategory.Media, inProfile.Audio, input);
if (DeviceInputResult.Status != AudioDeviceNodeCreationStatus.Success)
{
// Cannot create device input node
return;
}
// Set the Created Audio Input Node to Device Input Node
deviceInputNode = DeviceInputResult.DeviceInputNode;
// Create a device output node
var DeviceOutputResult = await micAudioGraph.CreateDeviceOutputNodeAsync();
if (DeviceOutputResult.Status != AudioDeviceNodeCreationStatus.Success)
{
// Cannot create device output node
return ;
}
// Selected Output device from Audio Graph is set to Device Output Node
deviceOutputNode = DeviceOutputResult.DeviceOutputNode;
// ################################################################################################
if (micAudioGraph == null)
return;
}