首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法安装VCD文件UWP installCommandDefinitionsFromStorageFileAsync

无法安装VCD文件UWP installCommandDefinitionsFromStorageFileAsync
EN

Stack Overflow用户
提问于 2016-12-22 19:05:38
回答 1查看 140关注 0票数 0

我将Cortana集成到我的应用程序(UWP和Winjs),但是当我试图安装VCD文件时,我得到了这个错误:

代码语言:javascript
复制
Status is 'error', but getResults did not return an error

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

代码语言:javascript
复制
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:

代码语言:javascript
复制
<?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“图书”,但真名是“图书”

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-28 06:59:24

我将Cortana集成到我的应用程序(UWP和Winjs),但是当我试图安装VCD文件时,我得到了一个错误:状态是‘错误’,但是getResults没有返回一个错误

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

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

虽然PhraseList或PhraseTopic是CommandSet的可选子级,但是您在VCD文件中为ListenFor和反馈元素定义了{book}{name},它们需要相应的PhraseList和Label属性值为name/book

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

代码语言:javascript
复制
<?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}</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>
    <PhraseList Label="book">
      <Item>London</Item>
      <Item>Las Vegas</Item>
      <Item>Melbourne</Item>
      <Item>Yosemite National Park</Item>
    </PhraseList>
    <PhraseList Label="number">
      <Item>2</Item>
      <Item>3</Item>
      <Item>4</Item>
      <Item>5</Item>
    </PhraseList>
  </CommandSet>
</VoiceCommands>

更多有关VCD文件的详细信息请参考本文件

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41290089

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档