1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

update voice

This commit is contained in:
Luke Pulverenti 2016-07-20 09:56:24 -04:00
parent 9ff21cf7b8
commit 79240b1a24
8 changed files with 90 additions and 125 deletions

View file

@ -15,12 +15,12 @@
}, },
"devDependencies": {}, "devDependencies": {},
"ignore": [], "ignore": [],
"version": "1.4.107", "version": "1.4.108",
"_release": "1.4.107", "_release": "1.4.108",
"_resolution": { "_resolution": {
"type": "version", "type": "version",
"tag": "1.4.107", "tag": "1.4.108",
"commit": "924bb12b6d7c3536ee00fc1a58ac4c492c36f559" "commit": "42932aca23d729123c468fa71c73d84483025aca"
}, },
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.0", "_target": "^1.2.0",

View file

@ -1,95 +1,32 @@
define(['dialogHelper', 'layoutManager', 'globalize', 'material-icons', 'css!./../prompt/style.css', 'emby-button', 'paper-icon-button-light'], function (dialogHelper, layoutManager, globalize) { define(['dialog', 'globalize'], function (dialog, globalize) {
function getIcon(icon, cssClass, canFocus, autoFocus) { return function (text, title) {
var tabIndex = canFocus ? '' : ' tabindex="-1"'; var options;
autoFocus = autoFocus ? ' autofocus' : ''; if (typeof text === 'string') {
return '<button is="paper-icon-button-light" class="autoSize ' + cssClass + '"' + tabIndex + autoFocus + '><i class="md-icon">' + icon + '</i></button>';
}
return function (options) {
if (typeof options === 'string') {
options = { options = {
title: '', title: title,
text: options text: text
}; };
}
var dialogOptions = {
removeOnClose: true
};
var backButton = false;
var raisedButtons = false;
var isFullscreen = false;
if (layoutManager.tv) {
dialogOptions.size = 'fullscreen';
backButton = true;
raisedButtons = true;
isFullscreen = true;
} else { } else {
options = text;
dialogOptions.modal = false;
dialogOptions.entryAnimationDuration = 160;
dialogOptions.exitAnimationDuration = 200;
} }
var dlg = dialogHelper.createDialog(dialogOptions); var items = [];
dlg.classList.add('promptDialog'); items.push({
name: globalize.translate('sharedcomponents#ButtonOk'),
var html = ''; id: 'ok'
html += '<div class="promptDialogContent">';
if (backButton) {
html += getIcon('&#xE5C4;', 'btnPromptExit', false);
}
if (options.title) {
html += '<h2>';
html += options.title;
html += '</h2>';
} else if (!isFullscreen) {
// Add a little space so it's not hugging the border
html += '<br/>';
}
var text = options.html || options.text;
if (text) {
if (options.title) {
html += '<p style="margin-top:2em;">';
} else {
html += '<p>';
}
html += text;
html += '</p>';
}
var buttonText = options.type == 'error' ? 'sharedcomponents#ButtonOk' : 'sharedcomponents#ButtonGotIt';
if (raisedButtons) {
html += '<button is="emby-button" type="button" class="raised btnSubmit"><i class="md-icon">check</i><span>' + globalize.translate(buttonText) + '</span></button>';
} else {
html += '<div class="buttons" style="text-align:right;">';
html += '<button is="emby-button" type="button" class="btnSubmit">' + globalize.translate(buttonText) + '</button>';
html += '</div>';
}
html += '</div>';
dlg.innerHTML = html;
document.body.appendChild(dlg);
dlg.querySelector('.btnSubmit').addEventListener('click', function (e) {
dialogHelper.close(dlg);
}); });
return dialogHelper.open(dlg); options.buttons = items;
return dialog(options).then(function (result) {
if (result == 'ok') {
return Promise.resolve();
}
return Promise.reject();
});
}; };
}); });

View file

@ -10,13 +10,15 @@
items = shuffleArray(items); items = shuffleArray(items);
} }
if (items.length) {
var serverId = items[0].ServerId;
items = items.map(function (i) { items = items.map(function (i) {
return i.Id; return i.Id;
}); });
if (items.length) {
playbackManager.play({ playbackManager.play({
ids: items ids: items,
serverId: serverId
}); });
} }
else { else {
@ -63,6 +65,7 @@
} }
var apiClient = connectionManager.currentApiClient(); var apiClient = connectionManager.currentApiClient();
if (result.item.sourceid === 'nextup') { if (result.item.sourceid === 'nextup') {
apiClient.getNextUpEpisodes(query).then(function (queryResult) { apiClient.getNextUpEpisodes(query).then(function (queryResult) {
@ -90,7 +93,6 @@
query.Filters = 'IsFavorite'; query.Filters = 'IsFavorite';
} }
apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) { apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) {
playItems(queryResult.Items, result.item.shuffle); playItems(queryResult.Items, result.item.shuffle);

View file

@ -85,7 +85,6 @@ define([], function () {
}, },
command: null, command: null,
text: text, text: text,
userId: Dashboard.getCurrentUserId(),
success: false success: false
}; };

View file

@ -1,4 +1,4 @@
define(['dialogHelper', './voicereceiver', './voiceprocessor', 'globalize', 'emby-button', 'css!./voice.css', 'material-icons', 'css!./../formdialog'], function (dialogHelper, voicereceiver, voiceprocessor, globalize) { define(['dialogHelper', 'voiceReceiver', 'voiceProcessor', 'globalize', 'emby-button', 'css!./voice.css', 'material-icons', 'css!./../formdialog'], function (dialogHelper, voicereceiver, voiceprocessor, globalize) {
var lang = 'en-US'; var lang = 'en-US';
@ -244,7 +244,11 @@ define(['dialogHelper', './voicereceiver', './voiceprocessor', 'globalize', 'emb
listen(); listen();
} }
function listen() { function listen() {
voicereceiver.listenForCommand(lang || "en-US").then(processInput).then(function (result) { voicereceiver.listen({
lang: lang || "en-US"
}).then(processInput).then(function (result) {
closeDialog(); closeDialog();

View file

@ -23,6 +23,8 @@
/// <returns> . </returns> /// <returns> . </returns>
function processTranscript(text) { function processTranscript(text) {
if (text) { if (text) {
return getCommandGroups().then(function (commandgroups) {
var processor = grammarprocessor(commandgroups, text); var processor = grammarprocessor(commandgroups, text);
if (processor && processor.command) { if (processor && processor.command) {
console.log("Command from Grammar Processor", processor); console.log("Command from Grammar Processor", processor);
@ -41,6 +43,7 @@
} else { } else {
return Promise.reject({ error: "unrecognized-command", text: text }); return Promise.reject({ error: "unrecognized-command", text: text });
} }
});
} else { } else {
return Promise.reject({ error: "empty" }); return Promise.reject({ error: "empty" });

View file

@ -1,10 +1,15 @@
define([], function () { define(['events'], function (events) {
var currentRecognition = null;
var receiver = {
};
var currentRecognition = null;
/// <summary> Starts listening for voice commands </summary> /// <summary> Starts listening for voice commands </summary>
/// <returns> . </returns> /// <returns> . </returns>
function listenForCommand(lang) { function listen(options) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {
cancelListener(); cancelListener();
@ -13,14 +18,29 @@
window.mozSpeechRecognition || window.mozSpeechRecognition ||
window.oSpeechRecognition || window.oSpeechRecognition ||
window.msSpeechRecognition)(); window.msSpeechRecognition)();
recognition.lang = lang;
recognition.lang = options.lang;
recognition.continuous = options.continuous || false;
var resultCount = 0;
recognition.onresult = function (event) { recognition.onresult = function (event) {
console.log(event); console.log(event);
if (event.results.length > 0) { if (event.results.length > 0) {
var resultInput = event.results[0][0].transcript || '';
var resultInput = event.results[resultCount][0].transcript || '';
resultCount++;
if (options.continuous) {
events.trigger(receiver, 'input', [
{
text: resultInput
}
]);
} else {
resolve(resultInput); resolve(resultInput);
} }
}
}; };
recognition.onerror = function () { recognition.onerror = function () {
@ -36,7 +56,6 @@
}); });
} }
/// <summary> Cancel listener. </summary> /// <summary> Cancel listener. </summary>
/// <returns> . </returns> /// <returns> . </returns>
function cancelListener() { function cancelListener() {
@ -48,10 +67,9 @@
} }
/// <summary> An enum constant representing the window. voice input manager option. </summary> receiver.listen = listen;
return { receiver.cancel = cancelListener;
listenForCommand: listenForCommand,
cancel: cancelListener
};
/// <summary> An enum constant representing the window. voice input manager option. </summary>
return receiver;
}); });

View file

@ -1830,6 +1830,8 @@ var AppInfo = {};
define("tvguide", [embyWebComponentsBowerPath + "/guide/guide", 'embyRouter'], returnFirstDependency); define("tvguide", [embyWebComponentsBowerPath + "/guide/guide", 'embyRouter'], returnFirstDependency);
define("voiceDialog", [embyWebComponentsBowerPath + "/voice/voicedialog"], returnFirstDependency); define("voiceDialog", [embyWebComponentsBowerPath + "/voice/voicedialog"], returnFirstDependency);
define("voiceReceiver", [embyWebComponentsBowerPath + "/voice/voicereceiver"], returnFirstDependency);
define("voiceProcessor", [embyWebComponentsBowerPath + "/voice/voiceprocessor"], returnFirstDependency);
define("viewManager", [embyWebComponentsBowerPath + "/viewmanager/viewmanager"], function (viewManager) { define("viewManager", [embyWebComponentsBowerPath + "/viewmanager/viewmanager"], function (viewManager) {
window.ViewManager = viewManager; window.ViewManager = viewManager;