2016-02-16 23:58:07 -07:00
|
|
|
|
// <date>09.10.2015</date>
|
|
|
|
|
// <summary>voicecommands class</summary>
|
2016-07-06 12:30:29 -07:00
|
|
|
|
define(['require'], function (require) {
|
2016-02-16 23:58:07 -07:00
|
|
|
|
|
|
|
|
|
/// <summary> Process the command. </summary>
|
|
|
|
|
/// <param name="commandPath"> Full pathname of the command file. </param>
|
|
|
|
|
/// <param name="result"> The result. </param>
|
|
|
|
|
/// <returns> . </returns>
|
|
|
|
|
function processCommand(commandPath, result) {
|
|
|
|
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
|
|
require([commandPath], function (command) {
|
|
|
|
|
command(result);
|
|
|
|
|
if (result.success) {
|
|
|
|
|
resolve(result);
|
|
|
|
|
}
|
|
|
|
|
reject();
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return function (result) {
|
|
|
|
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
|
|
|
|
|
|
switch (result.item.actionid) {
|
|
|
|
|
|
|
|
|
|
case 'show':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/showcommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'play':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/playcommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'shuffle':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/playcommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'search':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/searchcommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'control':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/controlcommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'enable':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/enablecommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'disable':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/disablecommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
case 'toggle':
|
2016-07-06 12:30:29 -07:00
|
|
|
|
processCommand('./commands/togglecommands.js', result).then(function (result) { resolve(result); });
|
2016-02-16 23:58:07 -07:00
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
reject();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|