diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/controlcommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/controlcommands.js index c1b46cc0e7..70e1ffde6a 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/controlcommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/controlcommands.js @@ -1,9 +1,15 @@ define(['playbackManager'], function (playbackManager) { + function setActiveDevice(name) { + return function () { + playbackManager.trySetActiveDeviceName(name); + }; + } + return function (result) { - result.success = true; + if (result.properties.devicename) { - playbackManager.trySetActiveDeviceName(result.properties.devicename); + return setActiveDevice(result.properties.devicename); } return; } diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/disablecommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/disablecommands.js index 20f1e004f6..908ebc109a 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/disablecommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/disablecommands.js @@ -1,13 +1,18 @@ define(['inputManager'], function (inputManager) { + function disableDisplayMirror() { + return function () { + inputManager.trigger('disabledisplaymirror'); + }; + } + return function (result) { - result.success = true; + switch (result.item.deviceid) { case 'displaymirroring': - inputManager.trigger('disabledisplaymirror'); + return disableDisplayMirror(); break; default: - result.success = false; return; } } diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/enablecommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/enablecommands.js index af88c8e432..2abbb86ea7 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/enablecommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/enablecommands.js @@ -1,13 +1,18 @@ define(['inputManager'], function (inputManager) { + function enableDisplayMirror() { + return function () { + inputManager.trigger('enabledisplaymirror'); + }; + } + return function (result) { - result.success = true; + switch (result.item.deviceid) { case 'displaymirroring': - inputManager.trigger('enabledisplaymirror'); + return enableDisplayMirror(); break; default: - result.success = false; return; } } diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/playcommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/playcommands.js index 7aedf49c6f..dcc659584c 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/playcommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/playcommands.js @@ -49,58 +49,52 @@ } return function (result) { - result.success = false; - var query = { + return function () { + var query = { - Limit: result.item.limit || 100, - UserId: result.userId, - ExcludeLocationTypes: "Virtual" - }; + Limit: result.item.limit || 100, + UserId: result.userId, + ExcludeLocationTypes: "Virtual" + }; - if (result.item.itemType) { - query.IncludeItemTypes = result.item.itemType; - } + if (result.item.itemType) { + query.IncludeItemTypes = result.item.itemType; + } - var apiClient = connectionManager.currentApiClient(); - if (result.item.sourceid === 'nextup') { + var apiClient = connectionManager.currentApiClient(); + if (result.item.sourceid === 'nextup') { - apiClient.getNextUpEpisodes(query).then(function (queryResult) { + apiClient.getNextUpEpisodes(query).then(function (queryResult) { + + playItems(queryResult.Items, result.item.shuffle); + + }); + } + + if (result.item.shuffle) { + result.item.sortBy = result.sortBy ? 'Random,' + result.item.sortBy : 'Random'; + } + + query.SortBy = result.item.sortBy; + query.SortOrder = result.item.sortOrder; + query.Recursive = true; + + if (result.item.filters.indexOf('unplayed') !== -1) { + query.IsPlayed = false; + } + if (result.item.filters.indexOf('played') !== -1) { + query.IsPlayed = true; + } + if (result.item.filters.indexOf('favorite') !== -1) { + query.Filters = 'IsFavorite'; + } + + + apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) { playItems(queryResult.Items, result.item.shuffle); - }); - result.success = true; - return; - } - - if (result.item.shuffle) { - result.item.sortBy = result.sortBy ? 'Random,' + result.item.sortBy : 'Random'; - } - - query.SortBy = result.item.sortBy; - query.SortOrder = result.item.sortOrder; - query.Recursive = true; - - if (result.item.filters.indexOf('unplayed') !== -1) { - query.IsPlayed = false; - } - if (result.item.filters.indexOf('played') !== -1) { - query.IsPlayed = true; - } - if (result.item.filters.indexOf('favorite') !== -1) { - query.Filters = 'IsFavorite'; - } - - - apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) { - - playItems(queryResult.Items, result.item.shuffle); - }); - - result.success = true; - - return; - + }; } }); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/searchcommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/searchcommands.js index 715114f9ca..4abf767677 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/searchcommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/searchcommands.js @@ -3,7 +3,6 @@ return function (result) { switch (result.item.deviceid) { default: - result.success = false; return; } } diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/showcommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/showcommands.js index 4446af9b53..08676adce4 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/showcommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/showcommands.js @@ -1,96 +1,131 @@ define(['inputManager', 'connectionManager', 'embyRouter'], function (inputManager, connectionManager, embyRouter) { - return function (result) { - result.success = true; - switch (result.item.sourceid) { - case 'music': - inputManager.trigger('music'); - break; - case 'movies': - if (result.properties.movieName) { + function getMusicCommand(result) { + return function () { + inputManager.trigger('music'); + }; + } - //TODO: Find a way to display movie - var query = { - Limit: 1, - UserId: result.userId, - ExcludeLocationTypes: "Virtual", - NameStartsWith: result.item.itemType - }; + function getMoviesCommand(result) { + return function () { + if (result.properties.movieName) { - if (result.item.itemType) { - query.IncludeItemTypes = result.item.itemType; - } + //TODO: Find a way to display movie + var query = { + Limit: 1, + UserId: result.userId, + ExcludeLocationTypes: "Virtual", + NameStartsWith: result.item.itemType + }; - var apiClient = connectionManager.currentApiClient(); - apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) { - - if (queryResult.Items.length) { - embyRouter.showItem(queryResult.Items[0]); - } - }); - - } else { - inputManager.trigger('movies'); + if (result.item.itemType) { + query.IncludeItemTypes = result.item.itemType; } - break; - case 'tvseries': - inputManager.trigger('tv'); - break; - case 'livetv': - var act = result.item.menuid; - if (act) { - if (act.indexOf('livetv') != -1) { - inputManager.trigger('livetv'); - } else if (act.indexOf('guide') != -1) { - inputManager.trigger('guide'); - } else if (act.indexOf('channels') != -1) { - inputManager.trigger('livetv'); - } else if (act.indexOf('recordings') != -1) { - inputManager.trigger('recordedtv'); - } else if (act.indexOf('scheduled') != -1) { - inputManager.trigger('recordedtv'); - } else if (act.indexOf('series') != -1) { - inputManager.trigger('recordedtv'); - } else { - inputManager.trigger('livetv'); + var apiClient = connectionManager.currentApiClient(); + apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) { + + if (queryResult.Items.length) { + embyRouter.showItem(queryResult.Items[0]); } + }); + + } else { + inputManager.trigger('movies'); + } + }; + } + + function getTVCommand(result) { + return function () { + inputManager.trigger('tv'); + }; + } + + function getLiveTVCommand(result) { + return function () { + var act = result.item.menuid; + if (act) { + if (act.indexOf('livetv') != -1) { + inputManager.trigger('livetv'); + } else if (act.indexOf('guide') != -1) { + inputManager.trigger('guide'); + } else if (act.indexOf('channels') != -1) { + inputManager.trigger('livetv'); + } else if (act.indexOf('recordings') != -1) { + inputManager.trigger('recordedtv'); + } else if (act.indexOf('scheduled') != -1) { + inputManager.trigger('recordedtv'); + } else if (act.indexOf('series') != -1) { + inputManager.trigger('recordedtv'); } else { inputManager.trigger('livetv'); } - break; - case 'recordings': - inputManager.trigger('recordedtv'); - break; - case 'latestepisodes': - inputManager.trigger('latestepisodes'); - case 'home': - var act = result.item.menuid; - if (act) { - if (act.indexOf('home') != -1) { - inputManager.trigger('home'); - } - else if (act.indexOf('nextup') != -1) { - inputManager.trigger('nextup'); - } - else if (act.indexOf('favorites') != -1) { - inputManager.trigger('favorites'); - } else if (act.indexOf('upcoming') != -1) { - inputManager.trigger('upcomingtv'); - } - else if (act.indexOf('nowplaying') != -1) { - inputManager.trigger('nowplaying'); - } - else { - inputManager.trigger('home'); - } - } else { + } else { + inputManager.trigger('livetv'); + } + }; + } + + function getRecordingsCommand(result) { + return function () { + inputManager.trigger('recordedtv'); + }; + } + + function getLatestEpisodesCommand(result) { + return function () { + inputManager.trigger('latestepisodes'); + }; + } + + function getHomeCommand(result) { + return function () { + var act = result.item.menuid; + if (act) { + if (act.indexOf('home') != -1) { inputManager.trigger('home'); } + else if (act.indexOf('nextup') != -1) { + inputManager.trigger('nextup'); + } + else if (act.indexOf('favorites') != -1) { + inputManager.trigger('favorites'); + } else if (act.indexOf('upcoming') != -1) { + inputManager.trigger('upcomingtv'); + } + else if (act.indexOf('nowplaying') != -1) { + inputManager.trigger('nowplaying'); + } + else { + inputManager.trigger('home'); + } + } else { + inputManager.trigger('home'); + } + }; + } + + return function (result) { + + switch (result.item.sourceid) { + case 'music': + return getMusicCommand(result); + case 'movies': + return getMoviesCommand(result); + case 'tvseries': + return getTVCommand(result); + case 'livetv': + return getLiveTVCommand(result); + case 'recordings': + return getRecordingsCommand(result); + case 'latestepisodes': + return getLatestEpisodesCommand(result); + case 'home': + return getHomeCommand(result); case 'group': - break; + return; default: - result.success = false; return; } diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/togglecommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/togglecommands.js index 9fa7382bd0..f9b2314e65 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/commands/togglecommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/commands/togglecommands.js @@ -1,14 +1,20 @@ define(['inputManager'], function (inputManager) { + function toggleDisplayMirror() { + return function () { + inputManager.trigger('toggledisplaymirror'); + }; + } + return function (result) { - result.success = true; + switch (result.item.deviceid) { case 'displaymirroring': - inputManager.trigger('toggledisplaymirror'); + return toggleDisplayMirror(); break; default: - result.success = false; return; } } + }); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/voicecommands.js b/dashboard-ui/bower_components/emby-webcomponents/voice/voicecommands.js index 0463cdf6e1..56169c9fd7 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/voicecommands.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/voicecommands.js @@ -11,11 +11,15 @@ define(['require'], function (require) { return new Promise(function (resolve, reject) { require([commandPath], function (command) { - command(result); - if (result.success) { + + var fn = command(result); + + if (fn) { + result.fn = fn; resolve(result); + } else { + reject(); } - reject(); }); }); @@ -23,38 +27,34 @@ define(['require'], function (require) { return function (result) { - return new Promise(function (resolve, reject) { + switch (result.item.actionid) { - switch (result.item.actionid) { - - case 'show': - processCommand('./commands/showcommands.js', result).then(function (result) { resolve(result); }); - break; - case 'play': - processCommand('./commands/playcommands.js', result).then(function (result) { resolve(result); }); - break; - case 'shuffle': - processCommand('./commands/playcommands.js', result).then(function (result) { resolve(result); }); - break; - case 'search': - processCommand('./commands/searchcommands.js', result).then(function (result) { resolve(result); }); - break; - case 'control': - processCommand('./commands/controlcommands.js', result).then(function (result) { resolve(result); }); - break; - case 'enable': - processCommand('./commands/enablecommands.js', result).then(function (result) { resolve(result); }); - break; - case 'disable': - processCommand('./commands/disablecommands.js', result).then(function (result) { resolve(result); }); - break; - case 'toggle': - processCommand('./commands/togglecommands.js', result).then(function (result) { resolve(result); }); - break; - default: - reject(); - return; - } - }); + case 'show': + return processCommand('./commands/showcommands.js', result); + break; + case 'play': + return processCommand('./commands/playcommands.js', result); + break; + case 'shuffle': + return processCommand('./commands/playcommands.js', result); + break; + case 'search': + return processCommand('./commands/searchcommands.js', result); + break; + case 'control': + return processCommand('./commands/controlcommands.js', result); + break; + case 'enable': + return processCommand('./commands/enablecommands.js', result); + break; + case 'disable': + return processCommand('./commands/disablecommands.js', result); + break; + case 'toggle': + return processCommand('./commands/togglecommands.js', result); + break; + default: + return Promise.reject(); + } } }); \ No newline at end of file diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/voicedialog.js b/dashboard-ui/bower_components/emby-webcomponents/voice/voicedialog.js index a7347339bc..8b6d038656 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/voicedialog.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/voicedialog.js @@ -247,10 +247,15 @@ define(['dialogHelper', './voicereceiver', './voiceprocessor', 'globalize', 'emb listen(); } function listen() { - voicereceiver.listenForCommand(lang || "en-US").then(processInput).then(function (data) { + voicereceiver.listenForCommand(lang || "en-US").then(processInput).then(function (result) { closeDialog(); + // Put a delay here in case navigation/popstate is involved. Allow that to flush out + setTimeout(function () { + result.fn(); + }, 1); + }, function (result) { if (result.error == 'group') { showVoiceHelp(result.item.groupid, result.groupName); diff --git a/dashboard-ui/bower_components/emby-webcomponents/voice/voiceprocessor.js b/dashboard-ui/bower_components/emby-webcomponents/voice/voiceprocessor.js index d193937b92..dfb8732ce2 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/voice/voiceprocessor.js +++ b/dashboard-ui/bower_components/emby-webcomponents/voice/voiceprocessor.js @@ -28,11 +28,12 @@ console.log("Command from Grammar Processor", processor); return voicecommands(processor) .then(function (result) { + console.log("Result of executed command", result); if (result.item.actionid === 'show' && result.item.sourceid === 'group') { - return Promise.resolve({ error: "group", item: result.item, groupName: result.name }); + return Promise.resolve({ error: "group", item: result.item, groupName: result.name, fn: result.fn }); } else { - return Promise.resolve({ item: result.item }); + return Promise.resolve({ item: result.item, fn: result.fn }); } }, function () { return Promise.reject({ error: "unrecognized-command", text: text }); diff --git a/dashboard-ui/scripts/wizardcomponents.js b/dashboard-ui/scripts/wizardcomponents.js index 2943a28dfa..875e92bc1c 100644 --- a/dashboard-ui/scripts/wizardcomponents.js +++ b/dashboard-ui/scripts/wizardcomponents.js @@ -18,7 +18,7 @@ view.querySelector('.fldSelectEncoderPathType').classList.remove('hide'); } - /*if (systemInfo.OperatingSystem == 'Windows' && systemInfo.SystemArchitecture != 'Arm') { + if (systemInfo.OperatingSystem == 'Windows' && systemInfo.SystemArchitecture != 'Arm') { view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', 'https://ffmpeg.zeranoe.com'); @@ -29,7 +29,7 @@ instructions = 'Download FFmpeg 64-Bit Static'; } - } else*/ if (systemInfo.OperatingSystem == 'Linux' && systemInfo.SystemArchitecture != 'Arm') { + } else if (systemInfo.OperatingSystem == 'Linux' && systemInfo.SystemArchitecture != 'Arm') { view.querySelector('.suggestedLocation').innerHTML = Globalize.translate('FFmpegSuggestedDownload', 'http://johnvansickle.com/ffmpeg');