Update voice components
This commit is contained in:
parent
c6b15e3001
commit
984b49650e
14 changed files with 1613 additions and 449 deletions
11
dashboard-ui/voice/commands/controlcommands.js
Normal file
11
dashboard-ui/voice/commands/controlcommands.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
return function (result) {
|
||||
result.success = true;
|
||||
if (result.properties.devicename)
|
||||
MediaController.trySetActiveDeviceName(result.properties.devicename);
|
||||
|
||||
return;
|
||||
}
|
||||
});
|
16
dashboard-ui/voice/commands/disablecommands.js
Normal file
16
dashboard-ui/voice/commands/disablecommands.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
return function (result) {
|
||||
result.success = true;
|
||||
switch (result.item.deviceid) {
|
||||
case 'displaymirroring':
|
||||
MediaController.enableDisplayMirroring(false);
|
||||
break;
|
||||
default:
|
||||
result.success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
16
dashboard-ui/voice/commands/enablecommands.js
Normal file
16
dashboard-ui/voice/commands/enablecommands.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
return function (result) {
|
||||
result.success = true;
|
||||
switch (result.item.deviceid) {
|
||||
case 'displaymirroring':
|
||||
MediaController.enableDisplayMirroring(true);
|
||||
break;
|
||||
default:
|
||||
result.success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
106
dashboard-ui/voice/commands/playcommands.js
Normal file
106
dashboard-ui/voice/commands/playcommands.js
Normal file
|
@ -0,0 +1,106 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
/// <summary> Play items. </summary>
|
||||
/// <param name="items"> The items. </param>
|
||||
/// <param name="shuffle"> The shuffle. </param>
|
||||
/// <returns> . </returns>
|
||||
function playItems(items, shuffle) {
|
||||
|
||||
if (shuffle) {
|
||||
items = shuffleArray(items);
|
||||
}
|
||||
|
||||
items = items.map(function (i) {
|
||||
return i.Id;
|
||||
});
|
||||
|
||||
if (items.length) {
|
||||
MediaController.play({
|
||||
ids: items
|
||||
});
|
||||
}
|
||||
else {
|
||||
Dashboard.alert({
|
||||
message: Globalize.translate('MessageNoItemsFound')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Shuffle array. </summary>
|
||||
/// <param name="array"> The array. </param>
|
||||
/// <returns> . </returns>
|
||||
function shuffleArray(array) {
|
||||
var currentIndex = array.length, temporaryValue, randomIndex;
|
||||
|
||||
// While there remain elements to shuffle...
|
||||
while (0 !== currentIndex) {
|
||||
|
||||
// Pick a remaining element...
|
||||
randomIndex = Math.floor(Math.random() * currentIndex);
|
||||
currentIndex -= 1;
|
||||
|
||||
// And swap it with the current element.
|
||||
temporaryValue = array[currentIndex];
|
||||
array[currentIndex] = array[randomIndex];
|
||||
array[randomIndex] = temporaryValue;
|
||||
}
|
||||
|
||||
return array;
|
||||
}
|
||||
|
||||
return function (result) {
|
||||
result.success = false;
|
||||
|
||||
var query = {
|
||||
|
||||
Limit: result.item.limit || 100,
|
||||
UserId: result.userId,
|
||||
ExcludeLocationTypes: "Virtual"
|
||||
};
|
||||
|
||||
if (result.item.itemType) {
|
||||
query.IncludeItemTypes = result.item.itemType;
|
||||
}
|
||||
|
||||
if (result.item.sourceid === 'nextup') {
|
||||
|
||||
ApiClient.getNextUpEpisodes(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(Dashboard.getCurrentUserId(), query).then(function (queryResult) {
|
||||
|
||||
playItems(queryResult.Items, result.item.shuffle);
|
||||
});
|
||||
|
||||
result.success = true;
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
});
|
16
dashboard-ui/voice/commands/searchcommands.js
Normal file
16
dashboard-ui/voice/commands/searchcommands.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
return function (result) {
|
||||
result.success = true;
|
||||
switch (result.item.deviceid) {
|
||||
case 'displaymirroring':
|
||||
MediaController.enableDisplayMirroring(false);
|
||||
break;
|
||||
default:
|
||||
result.success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
93
dashboard-ui/voice/commands/showcommands.js
Normal file
93
dashboard-ui/voice/commands/showcommands.js
Normal file
|
@ -0,0 +1,93 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
return function (result) {
|
||||
result.success = true;
|
||||
switch (result.item.sourceid) {
|
||||
case 'music':
|
||||
Dashboard.navigate('music.html');
|
||||
break;
|
||||
case 'movies':
|
||||
if (result.properties.movieName) {
|
||||
//TODO: Find a way to display movie
|
||||
var query = {
|
||||
|
||||
Limit: 1,
|
||||
UserId: result.userId,
|
||||
ExcludeLocationTypes: "Virtual"
|
||||
};
|
||||
|
||||
|
||||
if (result.item.itemType) {
|
||||
query.IncludeItemTypes = result.item.itemType;
|
||||
}
|
||||
|
||||
query.SearchTerm = result.properties.movieName;
|
||||
|
||||
ApiClient.getItems(Dashboard.getCurrentUserId(), query).then(function (queryResult) {
|
||||
|
||||
var s = queryResult[0];
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
else
|
||||
Dashboard.navigate('movies.html');
|
||||
|
||||
break;
|
||||
case 'tvseries':
|
||||
Dashboard.navigate('tv.html');
|
||||
break;
|
||||
case 'livetv':
|
||||
var act = result.item.menuid;
|
||||
if (act) {
|
||||
if (act.indexOf('livetv') != -1)
|
||||
Dashboard.navigate('livetv.html?tab=0');
|
||||
else if (act.indexOf('guide') != -1)
|
||||
Dashboard.navigate('livetv.html?tab=1');
|
||||
else if (act.indexOf('channels') != -1)
|
||||
Dashboard.navigate('livetv.html?tab=2');
|
||||
else if (act.indexOf('recordings') != -1)
|
||||
Dashboard.navigate('livetv.html?tab=3');
|
||||
else if (act.indexOf('scheduled') != -1)
|
||||
Dashboard.navigate('livetv.html?tab=4');
|
||||
else if (act.indexOf('series') != -1)
|
||||
Dashboard.navigate('livetv.html?tab=5');
|
||||
else
|
||||
Dashboard.navigate('livetv.html?tab=0');
|
||||
}
|
||||
else
|
||||
Dashboard.navigate('livetv.html?tab=0');
|
||||
break;
|
||||
case 'recordings':
|
||||
Dashboard.navigate('livetv.html?tab=3');
|
||||
break;
|
||||
case 'latestepisodes':
|
||||
Dashboard.navigate('tv.html?tab=1');
|
||||
case 'home':
|
||||
var act = result.item.menuid;
|
||||
if (act) {
|
||||
if (act.indexOf('home') != -1)
|
||||
Dashboard.navigate('index.html');
|
||||
else if (act.indexOf('nextup') != -1)
|
||||
Dashboard.navigate('index.html?tab=2');
|
||||
else if (act.indexOf('favorites') != -1)
|
||||
Dashboard.navigate('index.html?tab=2');
|
||||
else if (act.indexOf('upcoming') != -1)
|
||||
Dashboard.navigate('index.html?tab=3');
|
||||
else if (act.indexOf('nowplaying') != -1)
|
||||
Dashboard.navigate('nowplaying.html');
|
||||
else
|
||||
Dashboard.navigate('index.html');
|
||||
}
|
||||
else
|
||||
Dashboard.navigate('index.html');
|
||||
case 'group':
|
||||
break;
|
||||
default:
|
||||
result.success = false;
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
});
|
16
dashboard-ui/voice/commands/togglecommands.js
Normal file
16
dashboard-ui/voice/commands/togglecommands.js
Normal file
|
@ -0,0 +1,16 @@
|
|||
|
||||
define([], function () {
|
||||
|
||||
return function (result) {
|
||||
result.success = true;
|
||||
switch (result.item.deviceid) {
|
||||
case 'displaymirroring':
|
||||
MediaController.toggleDisplayMirroring();
|
||||
break;
|
||||
default:
|
||||
result.success = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue