【发布时间】:2017-05-08 11:44:22
【问题描述】:
我将 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 称为“书”,但真实名称是“libro”
【问题讨论】:
标签: javascript windows uwp winjs cortana