gpt4 book ai didi

c# - "AccessDenied"调用CreateDeviceInputNodeAsync时

转载 作者:可可西里 更新时间:2023-11-01 11:12:03 26 4
gpt4 key购买 nike

当我遵循 Microsoft's article 时出现“AccessDenied”错误使用 AudioDeviceInputNode 类。这是我的代码:

public sealed partial class MainPage : Page {
private AudioGraph graph = null;
private AudioDeviceInputNode deviceInputNode = null;

public MainPage() {
this.InitializeComponent();
}

private async Task CreateAudioGraph() {

// Create an AudioGraph with default settings
AudioGraphSettings settings = new AudioGraphSettings(AudioRenderCategory.Media);

CreateAudioGraphResult result = await AudioGraph.CreateAsync(settings);

if (result.Status != AudioGraphCreationStatus.Success) {
// Cannot create graph
await new ContentDialog() {
Title = "Error",
Content = String.Format("AudioGraph Creation Error because {0}", result.Status.ToString())
}.ShowAsync();
return;
}

graph = result.Graph;

// Create a device input node
CreateAudioDeviceInputNodeResult inputDeviceNodeResult = await graph.CreateDeviceInputNodeAsync(Windows.Media.Capture.MediaCategory.Other);

if (inputDeviceNodeResult.Status != AudioDeviceNodeCreationStatus.Success) {
// Cannot create device input node
await new ContentDialog() {
Title = "Error",
Content = String.Format("DeviceInputNode Creation Error because {0}", inputDeviceNodeResult.Status.ToString()),
PrimaryButtonText = "OK",
IsSecondaryButtonEnabled = false
}.ShowAsync();
return;
}
deviceInputNode = inputDeviceNodeResult.DeviceInputNode;
}

private async void button_Click(object sender, RoutedEventArgs e) {
await CreateAudioGraph();
}
}

但我能够运行 official sample .关于这个问题有什么想法吗?

最佳答案

我想通了。当你想使用AudioDeviceInputNode时,你需要在你的项目中打开Package.appxmanifest并在Capabilities选项卡中勾选“Microphone”。

关于c# - "AccessDenied"调用CreateDeviceInputNodeAsync时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34965096/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com