无法安装VCD文件UWP installCommandDefinitionsFromStorageFileAsync

时间:2016-12-22 19:05:39

标签: javascript windows uwp winjs cortana

我将Cortana集成到我的应用程序(带Winjs的UWP)但是当我尝试安装VCD文件时出现了错误:

Status is 'error', but getResults did not return an error

main.js(代码包含在应用程序的激活处理程序事件上):

wap.current.installedLocation.getFileAsync("Commands.xml").then(function (file) {
    return voiceCommandManager.installCommandDefinitionsFromStorageFileAsync(file);
}, function (er) {
    console.error('error file Commands.xml', er);
}).then(function () {
    var language = window.navigator.userLanguage || window.navigator.language;

    var commandSetName = "BibleCommandSet_" + language.toLowerCase();
    if (voiceCommandManager.installedCommandDefinitions.hasKey(commandSetName)) {
        var vcd = voiceCommandManager.installedCommandDefinitions.lookup(commandSetName);
    } else {
        console.log('VCD not installed yet?');
    }
}, function (ee) {
    console.error("installCommandDefinitionsFromStorageFileAsync error", ee);
});

Commands.xml:

<?xml version="1.0" encoding="utf-8" ?>
<VoiceCommands xmlns="http://schemas.microsoft.com/voicecommands/1.2">
    <CommandSet xml:lang="en-us" Name="BibleCommandSet_en-us">
        <AppName> Bible </AppName>
        <Example> Go to genesis 1,9 </Example>
        <Command Name="goToQuote">
            <Example> Go to genesis 1,9 </Example>
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}</ListenFor>
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> show {book} {number}{number}</ListenFor>
            ...
            <ListenFor RequireAppName="BeforeOrAfterPhrase"> open {book} {number}{number},{number}{number}</ListenFor>
            <Feedback> Ok i'm opening {book} </Feedback>
            <Navigate/>
        </Command>
    </CommandSet>

修正:在文件的另一行我有另一个commandSet,我确实调用了PhraseList“book”,但真名是“libro”

1 个答案:

答案 0 :(得分:0)

  

我将Cortana集成到我的应用程序(带Winjs的UWP)但是当我尝试安装VCD文件时出现了错误:状态为'错误',但getResults未返回错误

这是因为您的VCD文件有问题 - Command.xml。由于VCD文件发生错误而不是代码本身,因此您没有收到错误详细信息。

VCD文件中的特殊字符{}包含要引用的PhraseList或PhraseTopic的Label属性的值。在ListenFor或Feedback元素中使用。 Feedback元素中的PhraseList或PhraseTopic引用必须与同一命令中的ListenFor元素中的相应引用匹配。

尽管PhraseList或PhraseTopic是CommandSet的可选子项,但您为VCD文件中的ListenFor和Feedback元素定义了{book}{name},其中需要具有Label属性值的对应PhraseList为{{1 } / name

我根据您更新了VCD文件,现在代码可以成功运行。

book

有关VCD文件的更多详情,请参阅this document

相关问题