作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
当我遵循 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/
我是一名优秀的程序员,十分优秀!