mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update voice
This commit is contained in:
parent
9ff21cf7b8
commit
79240b1a24
8 changed files with 90 additions and 125 deletions
|
@ -15,12 +15,12 @@
|
|||
},
|
||||
"devDependencies": {},
|
||||
"ignore": [],
|
||||
"version": "1.4.107",
|
||||
"_release": "1.4.107",
|
||||
"version": "1.4.108",
|
||||
"_release": "1.4.108",
|
||||
"_resolution": {
|
||||
"type": "version",
|
||||
"tag": "1.4.107",
|
||||
"commit": "924bb12b6d7c3536ee00fc1a58ac4c492c36f559"
|
||||
"tag": "1.4.108",
|
||||
"commit": "42932aca23d729123c468fa71c73d84483025aca"
|
||||
},
|
||||
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
|
||||
"_target": "^1.2.0",
|
||||
|
|
|
@ -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"';
|
||||
autoFocus = autoFocus ? ' autofocus' : '';
|
||||
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') {
|
||||
var options;
|
||||
if (typeof text === 'string') {
|
||||
options = {
|
||||
title: '',
|
||||
text: options
|
||||
title: title,
|
||||
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 {
|
||||
|
||||
dialogOptions.modal = false;
|
||||
dialogOptions.entryAnimationDuration = 160;
|
||||
dialogOptions.exitAnimationDuration = 200;
|
||||
options = text;
|
||||
}
|
||||
|
||||
var dlg = dialogHelper.createDialog(dialogOptions);
|
||||
var items = [];
|
||||
|
||||
dlg.classList.add('promptDialog');
|
||||
|
||||
var html = '';
|
||||
|
||||
html += '<div class="promptDialogContent">';
|
||||
if (backButton) {
|
||||
html += getIcon('', '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);
|
||||
items.push({
|
||||
name: globalize.translate('sharedcomponents#ButtonOk'),
|
||||
id: 'ok'
|
||||
});
|
||||
|
||||
return dialogHelper.open(dlg);
|
||||
options.buttons = items;
|
||||
|
||||
return dialog(options).then(function (result) {
|
||||
if (result == 'ok') {
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
return Promise.reject();
|
||||
});
|
||||
};
|
||||
});
|
|
@ -10,13 +10,15 @@
|
|||
items = shuffleArray(items);
|
||||
}
|
||||
|
||||
items = items.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
if (items.length) {
|
||||
var serverId = items[0].ServerId;
|
||||
items = items.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
playbackManager.play({
|
||||
ids: items
|
||||
ids: items,
|
||||
serverId: serverId
|
||||
});
|
||||
}
|
||||
else {
|
||||
|
@ -63,6 +65,7 @@
|
|||
}
|
||||
|
||||
var apiClient = connectionManager.currentApiClient();
|
||||
|
||||
if (result.item.sourceid === 'nextup') {
|
||||
|
||||
apiClient.getNextUpEpisodes(query).then(function (queryResult) {
|
||||
|
@ -90,7 +93,6 @@
|
|||
query.Filters = 'IsFavorite';
|
||||
}
|
||||
|
||||
|
||||
apiClient.getItems(apiClient.getCurrentUserId(), query).then(function (queryResult) {
|
||||
|
||||
playItems(queryResult.Items, result.item.shuffle);
|
||||
|
|
|
@ -85,7 +85,6 @@ define([], function () {
|
|||
},
|
||||
command: null,
|
||||
text: text,
|
||||
userId: Dashboard.getCurrentUserId(),
|
||||
success: false
|
||||
};
|
||||
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
@ -244,7 +244,11 @@ define(['dialogHelper', './voicereceiver', './voiceprocessor', 'globalize', 'emb
|
|||
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();
|
||||
|
||||
|
|
|
@ -23,24 +23,27 @@
|
|||
/// <returns> . </returns>
|
||||
function processTranscript(text) {
|
||||
if (text) {
|
||||
var processor = grammarprocessor(commandgroups, text);
|
||||
if (processor && processor.command) {
|
||||
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, fn: result.fn });
|
||||
} else {
|
||||
return Promise.resolve({ item: result.item, fn: result.fn });
|
||||
}
|
||||
}, function () {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
});
|
||||
} else {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
}
|
||||
return getCommandGroups().then(function (commandgroups) {
|
||||
var processor = grammarprocessor(commandgroups, text);
|
||||
if (processor && processor.command) {
|
||||
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, fn: result.fn });
|
||||
} else {
|
||||
return Promise.resolve({ item: result.item, fn: result.fn });
|
||||
}
|
||||
}, function () {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
});
|
||||
} else {
|
||||
return Promise.reject({ error: "unrecognized-command", text: text });
|
||||
}
|
||||
});
|
||||
|
||||
} else {
|
||||
return Promise.reject({ error: "empty" });
|
||||
|
|
|
@ -1,10 +1,15 @@
|
|||
define([], function () {
|
||||
var currentRecognition = null;
|
||||
define(['events'], function (events) {
|
||||
|
||||
var receiver = {
|
||||
|
||||
};
|
||||
|
||||
var currentRecognition = null;
|
||||
|
||||
/// <summary> Starts listening for voice commands </summary>
|
||||
/// <returns> . </returns>
|
||||
function listenForCommand(lang) {
|
||||
function listen(options) {
|
||||
|
||||
return new Promise(function (resolve, reject) {
|
||||
cancelListener();
|
||||
|
||||
|
@ -13,13 +18,28 @@
|
|||
window.mozSpeechRecognition ||
|
||||
window.oSpeechRecognition ||
|
||||
window.msSpeechRecognition)();
|
||||
recognition.lang = lang;
|
||||
|
||||
recognition.lang = options.lang;
|
||||
recognition.continuous = options.continuous || false;
|
||||
|
||||
var resultCount = 0;
|
||||
|
||||
recognition.onresult = function (event) {
|
||||
console.log(event);
|
||||
if (event.results.length > 0) {
|
||||
var resultInput = event.results[0][0].transcript || '';
|
||||
resolve(resultInput);
|
||||
|
||||
var resultInput = event.results[resultCount][0].transcript || '';
|
||||
resultCount++;
|
||||
|
||||
if (options.continuous) {
|
||||
events.trigger(receiver, 'input', [
|
||||
{
|
||||
text: resultInput
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
resolve(resultInput);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -36,7 +56,6 @@
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Cancel listener. </summary>
|
||||
/// <returns> . </returns>
|
||||
function cancelListener() {
|
||||
|
@ -48,10 +67,9 @@
|
|||
|
||||
}
|
||||
|
||||
/// <summary> An enum constant representing the window. voice input manager option. </summary>
|
||||
return {
|
||||
listenForCommand: listenForCommand,
|
||||
cancel: cancelListener
|
||||
};
|
||||
receiver.listen = listen;
|
||||
receiver.cancel = cancelListener;
|
||||
|
||||
/// <summary> An enum constant representing the window. voice input manager option. </summary>
|
||||
return receiver;
|
||||
});
|
|
@ -1830,6 +1830,8 @@ var AppInfo = {};
|
|||
|
||||
define("tvguide", [embyWebComponentsBowerPath + "/guide/guide", 'embyRouter'], 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) {
|
||||
window.ViewManager = viewManager;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue