2019-10-15 21:13:33 +03:00
|
|
|
define(["apphost", "globalize", "connectionManager", "itemHelper", "appRouter", "playbackManager", "loading", "appSettings", "browser", "actionsheet"], function (appHost, globalize, connectionManager, itemHelper, appRouter, playbackManager, loading, appSettings, browser, actionsheet) {
|
|
|
|
"use strict";
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function getCommands(options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var item = options.item;
|
2019-12-07 12:20:32 +03:00
|
|
|
var user = options.user;
|
|
|
|
|
2019-01-10 15:39:37 +03:00
|
|
|
var canPlay = playbackManager.canPlay(item);
|
2019-08-19 12:35:57 +03:00
|
|
|
var restrictOptions = (browser.operaTv || browser.web0s) && !user.Policy.IsAdministrator;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-08-19 12:35:57 +03:00
|
|
|
var commands = [];
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (canPlay && item.MediaType !== "Photo") {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (options.play !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Play"),
|
|
|
|
id: "resume",
|
2020-02-16 01:31:14 +01:00
|
|
|
icon: ""
|
2019-08-19 12:35:57 +03:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (options.playAllFromHere && item.Type !== "Program" && item.Type !== "TvChannel") {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("PlayAllFromHere"),
|
|
|
|
id: "playallfromhere",
|
2020-02-16 01:31:14 +01:00
|
|
|
icon: ""
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (playbackManager.canQueue(item)) {
|
|
|
|
if (options.queue !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("AddToPlayQueue"),
|
|
|
|
id: "queue",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "playlist_add"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.queue !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("PlayNext"),
|
|
|
|
id: "queuenext",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "playlist_add"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
//if (options.queueAllFromHere) {
|
|
|
|
// commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
// name: globalize.translate("QueueAllFromHere"),
|
|
|
|
// id: "queueallfromhere"
|
2019-01-10 15:39:37 +03:00
|
|
|
// });
|
|
|
|
//}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.IsFolder || item.Type === "MusicArtist" || item.Type === "MusicGenre") {
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.CollectionType !== "livetv") {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (options.shuffle !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Shuffle"),
|
|
|
|
id: "shuffle",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "shuffle"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.MediaType === "Audio" || item.Type === "MusicAlbum" || item.Type === "MusicArtist" || item.Type === "MusicGenre") {
|
|
|
|
if (options.instantMix !== false && !itemHelper.isLocalItem(item)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("InstantMix"),
|
|
|
|
id: "instantmix",
|
2020-01-11 15:28:19 +09:00
|
|
|
icon: "explore"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (commands.length) {
|
|
|
|
commands.push({
|
|
|
|
divider: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!restrictOptions) {
|
|
|
|
if (itemHelper.supportsAddingToCollection(item)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("AddToCollection"),
|
|
|
|
id: "addtocollection",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "playlist_add"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemHelper.supportsAddingToPlaylist(item)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("AddToPlaylist"),
|
|
|
|
id: "addtoplaylist",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "playlist_add"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if ((item.Type === "Timer") && user.Policy.EnableLiveTvManagement && options.cancelTimer !== false) {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("CancelRecording"),
|
|
|
|
id: "canceltimer",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "cancel"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if ((item.Type === "Recording" && item.Status === "InProgress") && user.Policy.EnableLiveTvManagement && options.cancelTimer !== false) {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("CancelRecording"),
|
|
|
|
id: "canceltimer",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "cancel"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if ((item.Type === "SeriesTimer") && user.Policy.EnableLiveTvManagement && options.cancelTimer !== false) {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("CancelSeries"),
|
|
|
|
id: "cancelseriestimer",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "cancel"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.CanDelete && options.deleteItem !== false) {
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.Type === "Playlist" || item.Type === "BoxSet") {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Delete"),
|
|
|
|
id: "delete",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "delete"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("DeleteMedia"),
|
|
|
|
id: "delete",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "delete"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-07-28 15:51:02 +02:00
|
|
|
// Books are promoted to major download Button and therefor excluded in the context menu
|
2019-10-15 21:13:33 +03:00
|
|
|
if ((item.CanDownload && appHost.supports("filedownload")) && item.Type !== "Book") {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Download"),
|
|
|
|
id: "download",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "file_download"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2019-08-27 17:32:35 +08:00
|
|
|
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("CopyStreamURL"),
|
|
|
|
id: "copy-stream",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "content_copy"
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (commands.length) {
|
|
|
|
commands.push({
|
|
|
|
divider: true
|
2019-08-27 17:32:35 +08:00
|
|
|
});
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
var canEdit = itemHelper.canEdit(user, item);
|
2019-01-10 15:39:37 +03:00
|
|
|
if (canEdit) {
|
2019-10-15 21:13:33 +03:00
|
|
|
if (options.edit !== false && item.Type !== "SeriesTimer") {
|
|
|
|
var text = (item.Type === "Timer" || item.Type === "SeriesTimer") ? globalize.translate("Edit") : globalize.translate("EditMetadata");
|
2019-08-19 12:35:57 +03:00
|
|
|
commands.push({
|
|
|
|
name: text,
|
2019-10-15 21:13:33 +03:00
|
|
|
id: "edit",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "edit"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (itemHelper.canEditImages(user, item)) {
|
|
|
|
if (options.editImages !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("EditImages"),
|
|
|
|
id: "editimages",
|
2020-01-11 15:33:53 +09:00
|
|
|
icon: "image"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (canEdit) {
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.MediaType === "Video" && item.Type !== "TvChannel" && item.Type !== "Program" && item.LocationType !== "Virtual" && !(item.Type === "Recording" && item.Status !== "Completed")) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (options.editSubtitles !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("EditSubtitles"),
|
|
|
|
id: "editsubtitles",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "closed_caption"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.identify !== false) {
|
|
|
|
if (itemHelper.canIdentify(user, item)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Identify"),
|
|
|
|
id: "identify",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "edit"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-19 12:35:57 +03:00
|
|
|
if (item.MediaSources) {
|
|
|
|
if (options.moremediainfo !== false) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("MoreMediaInfo"),
|
|
|
|
id: "moremediainfo",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "info"
|
2019-08-19 12:35:57 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.Type === "Program" && options.record !== false) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (item.TimerId) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: Globalize.translate("ManageRecording"),
|
|
|
|
id: "record",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "fiber_manual_record"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.Type === "Program" && options.record !== false) {
|
2019-01-10 15:39:37 +03:00
|
|
|
if (!item.TimerId) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: Globalize.translate("Record"),
|
|
|
|
id: "record",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "fiber_manual_record"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (itemHelper.canRefreshMetadata(item, user)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("RefreshMetadata"),
|
|
|
|
id: "refresh",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "refresh"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (item.PlaylistItemId && options.playlistId) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("RemoveFromPlaylist"),
|
|
|
|
id: "removefromplaylist",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "remove"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.collectionId) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("RemoveFromCollection"),
|
|
|
|
id: "removefromcollection",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "remove"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!restrictOptions) {
|
|
|
|
if (options.share === true) {
|
|
|
|
if (itemHelper.canShare(item, user)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Share"),
|
|
|
|
id: "share",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "share"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.sync !== false) {
|
|
|
|
if (itemHelper.canSync(user, item)) {
|
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: globalize.translate("Sync"),
|
|
|
|
id: "sync",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "sync"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (options.openAlbum !== false && item.AlbumId && item.MediaType !== "Photo") {
|
2019-01-10 15:39:37 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: Globalize.translate("ViewAlbum"),
|
|
|
|
id: "album",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "album"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (options.openArtist !== false && item.ArtistItems && item.ArtistItems.length) {
|
2018-10-23 01:05:09 +03:00
|
|
|
commands.push({
|
2019-10-15 21:13:33 +03:00
|
|
|
name: Globalize.translate("ViewArtist"),
|
|
|
|
id: "artist",
|
2019-10-12 21:32:05 +03:00
|
|
|
icon: "person"
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
return commands;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function getResolveFunction(resolve, id, changed, deleted) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return function () {
|
2018-10-23 01:05:09 +03:00
|
|
|
resolve({
|
|
|
|
command: id,
|
|
|
|
updated: changed,
|
|
|
|
deleted: deleted
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
};
|
2019-08-19 12:35:57 +03:00
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
|
|
|
|
function executeCommand(item, id, options) {
|
2019-01-10 15:39:37 +03:00
|
|
|
var itemId = item.Id;
|
|
|
|
var serverId = item.ServerId;
|
|
|
|
var apiClient = connectionManager.getApiClient(serverId);
|
|
|
|
|
|
|
|
return new Promise(function (resolve, reject) {
|
2018-10-23 01:05:09 +03:00
|
|
|
switch (id) {
|
2019-10-15 21:13:33 +03:00
|
|
|
case "addtocollection":
|
|
|
|
require(["collectionEditor"], function (collectionEditor) {
|
2019-08-19 12:35:57 +03:00
|
|
|
new collectionEditor().show({
|
2019-01-10 15:41:25 +03:00
|
|
|
items: [itemId],
|
|
|
|
serverId: serverId
|
2019-08-19 12:35:57 +03:00
|
|
|
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "addtoplaylist":
|
|
|
|
require(["playlistEditor"], function (playlistEditor) {
|
2019-08-19 12:35:57 +03:00
|
|
|
new playlistEditor().show({
|
2019-01-10 15:41:25 +03:00
|
|
|
items: [itemId],
|
|
|
|
serverId: serverId
|
2019-08-19 12:35:57 +03:00
|
|
|
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "download":
|
|
|
|
require(["fileDownloader"], function (fileDownloader) {
|
2019-01-10 15:41:25 +03:00
|
|
|
var downloadHref = apiClient.getItemDownloadUrl(itemId);
|
2019-08-19 12:35:57 +03:00
|
|
|
fileDownloader.download([{
|
|
|
|
url: downloadHref,
|
|
|
|
itemId: itemId,
|
|
|
|
serverId: serverId
|
|
|
|
}]);
|
|
|
|
getResolveFunction(getResolveFunction(resolve, id), id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "copy-stream":
|
2019-08-27 17:32:35 +08:00
|
|
|
var downloadHref = apiClient.getItemDownloadUrl(itemId);
|
2020-03-12 03:12:01 -05:00
|
|
|
var textAreaCopy = function () {
|
2020-02-02 14:13:43 +01:00
|
|
|
var textArea = document.createElement("textarea");
|
|
|
|
textArea.value = downloadHref;
|
|
|
|
document.body.appendChild(textArea);
|
|
|
|
textArea.focus();
|
|
|
|
textArea.select();
|
2020-04-04 21:29:53 +02:00
|
|
|
|
2020-02-02 14:13:43 +01:00
|
|
|
if (document.execCommand("copy")) {
|
|
|
|
require(["toast"], function (toast) {
|
|
|
|
toast(globalize.translate("CopyStreamURLSuccess"));
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
prompt(globalize.translate("CopyStreamURL"), downloadHref);
|
|
|
|
}
|
|
|
|
document.body.removeChild(textArea);
|
2020-03-12 02:50:18 -05:00
|
|
|
};
|
2020-04-04 21:29:53 +02:00
|
|
|
|
|
|
|
/* eslint-disable-next-line compat/compat */
|
2020-03-12 02:50:18 -05:00
|
|
|
if (navigator.clipboard === undefined) {
|
2020-03-12 03:22:04 -05:00
|
|
|
textAreaCopy();
|
2020-03-12 02:50:18 -05:00
|
|
|
} else {
|
2020-04-04 21:29:53 +02:00
|
|
|
/* eslint-disable-next-line compat/compat */
|
2020-03-12 02:50:18 -05:00
|
|
|
navigator.clipboard.writeText(downloadHref).then(function () {
|
|
|
|
require(["toast"], function (toast) {
|
|
|
|
toast(globalize.translate("CopyStreamURLSuccess"));
|
|
|
|
});
|
2020-04-04 21:29:53 +02:00
|
|
|
}).catch(function () {
|
|
|
|
textAreaCopy();
|
|
|
|
});
|
2020-03-12 02:50:18 -05:00
|
|
|
}
|
2019-08-27 17:32:35 +08:00
|
|
|
getResolveFunction(resolve, id)();
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "editsubtitles":
|
|
|
|
require(["subtitleEditor"], function (subtitleEditor) {
|
2019-08-19 12:35:57 +03:00
|
|
|
subtitleEditor.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "edit":
|
2019-08-19 12:35:57 +03:00
|
|
|
editItem(apiClient, item).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "editimages":
|
|
|
|
require(["imageEditor"], function (imageEditor) {
|
2019-01-10 15:41:25 +03:00
|
|
|
imageEditor.show({
|
|
|
|
itemId: itemId,
|
|
|
|
serverId: serverId
|
2019-08-19 12:35:57 +03:00
|
|
|
}).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "identify":
|
|
|
|
require(["itemIdentifier"], function (itemIdentifier) {
|
2019-08-19 12:35:57 +03:00
|
|
|
itemIdentifier.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "moremediainfo":
|
|
|
|
require(["itemMediaInfo"], function (itemMediaInfo) {
|
2019-08-19 12:35:57 +03:00
|
|
|
itemMediaInfo.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "refresh":
|
2019-08-19 12:35:57 +03:00
|
|
|
refresh(apiClient, item);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "open":
|
2019-08-19 12:35:57 +03:00
|
|
|
appRouter.showItem(item);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "play":
|
2019-08-19 12:35:57 +03:00
|
|
|
play(item, false);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "resume":
|
2019-08-19 12:35:57 +03:00
|
|
|
play(item, true);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "queue":
|
2019-08-19 12:35:57 +03:00
|
|
|
play(item, false, true);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "queuenext":
|
2019-08-19 12:35:57 +03:00
|
|
|
play(item, false, true, true);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "record":
|
|
|
|
require(["recordingCreator"], function (recordingCreator) {
|
2019-01-10 15:39:37 +03:00
|
|
|
recordingCreator.show(itemId, serverId).then(getResolveFunction(resolve, id, true), getResolveFunction(resolve, id));
|
2018-10-23 01:05:09 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "shuffle":
|
2019-08-19 12:35:57 +03:00
|
|
|
playbackManager.shuffle(item);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "instantmix":
|
2019-08-19 12:35:57 +03:00
|
|
|
playbackManager.instantMix(item);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "delete":
|
2019-08-19 12:35:57 +03:00
|
|
|
deleteItem(apiClient, item).then(getResolveFunction(resolve, id, true, true), getResolveFunction(resolve, id));
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "share":
|
2019-01-10 15:41:25 +03:00
|
|
|
navigator.share({
|
|
|
|
title: item.Name,
|
|
|
|
text: item.Overview,
|
|
|
|
url: "https://github.com/jellyfin/jellyfin"
|
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "album":
|
2019-03-18 22:22:48 -07:00
|
|
|
appRouter.showItem(item.AlbumId, item.ServerId);
|
|
|
|
getResolveFunction(resolve, id)();
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "artist":
|
2019-03-18 22:22:48 -07:00
|
|
|
appRouter.showItem(item.ArtistItems[0].Id, item.ServerId);
|
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "playallfromhere":
|
2019-03-18 22:22:48 -07:00
|
|
|
getResolveFunction(resolve, id)();
|
2019-01-10 15:41:25 +03:00
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "queueallfromhere":
|
2019-01-10 15:41:25 +03:00
|
|
|
getResolveFunction(resolve, id)();
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "removefromplaylist":
|
2018-10-23 01:05:09 +03:00
|
|
|
apiClient.ajax({
|
2019-10-15 21:13:33 +03:00
|
|
|
url: apiClient.getUrl("Playlists/" + options.playlistId + "/Items", {
|
|
|
|
EntryIds: [item.PlaylistItemId].join(",")
|
2018-10-23 01:05:09 +03:00
|
|
|
}),
|
2019-10-15 21:13:33 +03:00
|
|
|
type: "DELETE"
|
2019-01-10 15:39:37 +03:00
|
|
|
}).then(function () {
|
|
|
|
getResolveFunction(resolve, id, true)();
|
2018-10-23 01:05:09 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "removefromcollection":
|
2018-10-23 01:05:09 +03:00
|
|
|
apiClient.ajax({
|
|
|
|
type: "DELETE",
|
|
|
|
url: apiClient.getUrl("Collections/" + options.collectionId + "/Items", {
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
Ids: [item.Id].join(",")
|
2018-10-23 01:05:09 +03:00
|
|
|
})
|
2019-01-10 15:39:37 +03:00
|
|
|
}).then(function () {
|
|
|
|
getResolveFunction(resolve, id, true)();
|
2018-10-23 01:05:09 +03:00
|
|
|
});
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "canceltimer":
|
2018-10-23 01:05:09 +03:00
|
|
|
deleteTimer(apiClient, item, resolve, id);
|
|
|
|
break;
|
2019-10-15 21:13:33 +03:00
|
|
|
case "cancelseriestimer":
|
2018-10-23 01:05:09 +03:00
|
|
|
deleteSeriesTimer(apiClient, item, resolve, id);
|
|
|
|
break;
|
|
|
|
default:
|
2019-01-10 15:39:37 +03:00
|
|
|
reject();
|
|
|
|
break;
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteTimer(apiClient, item, resolve, command) {
|
2019-10-15 21:13:33 +03:00
|
|
|
require(["recordingHelper"], function (recordingHelper) {
|
2018-10-23 01:05:09 +03:00
|
|
|
var timerId = item.TimerId || item.Id;
|
2019-01-10 15:39:37 +03:00
|
|
|
recordingHelper.cancelTimerWithConfirmation(timerId, item.ServerId).then(function () {
|
|
|
|
getResolveFunction(resolve, command, true)();
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteSeriesTimer(apiClient, item, resolve, command) {
|
2019-10-15 21:13:33 +03:00
|
|
|
require(["recordingHelper"], function (recordingHelper) {
|
2019-01-10 15:39:37 +03:00
|
|
|
recordingHelper.cancelSeriesTimerWithConfirmation(item.Id, item.ServerId).then(function () {
|
|
|
|
getResolveFunction(resolve, command, true)();
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function play(item, resume, queue, queueNext) {
|
2019-10-15 21:13:33 +03:00
|
|
|
var method = queue ? (queueNext ? "queueNext" : "queue") : "play";
|
2019-01-10 15:39:37 +03:00
|
|
|
|
|
|
|
var startPosition = 0;
|
|
|
|
if (resume && item.UserData && item.UserData.PlaybackPositionTicks) {
|
|
|
|
startPosition = item.UserData.PlaybackPositionTicks;
|
|
|
|
}
|
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.Type === "Program") {
|
2019-01-10 15:39:37 +03:00
|
|
|
playbackManager[method]({
|
2019-08-19 12:35:57 +03:00
|
|
|
ids: [item.ChannelId],
|
|
|
|
startPositionTicks: startPosition,
|
|
|
|
serverId: item.ServerId
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
playbackManager[method]({
|
2019-08-19 12:35:57 +03:00
|
|
|
items: [item],
|
|
|
|
startPositionTicks: startPosition
|
2019-01-10 15:39:37 +03:00
|
|
|
});
|
|
|
|
}
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function editItem(apiClient, item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return new Promise(function (resolve, reject) {
|
2018-10-23 01:05:09 +03:00
|
|
|
var serverId = apiClient.serverInfo().Id;
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2019-10-15 21:13:33 +03:00
|
|
|
if (item.Type === "Timer") {
|
|
|
|
require(["recordingEditor"], function (recordingEditor) {
|
2019-01-10 15:39:37 +03:00
|
|
|
recordingEditor.show(item.Id, serverId).then(resolve, reject);
|
|
|
|
});
|
2019-10-15 21:13:33 +03:00
|
|
|
} else if (item.Type === "SeriesTimer") {
|
|
|
|
require(["seriesRecordingEditor"], function (recordingEditor) {
|
2019-01-10 15:39:37 +03:00
|
|
|
recordingEditor.show(item.Id, serverId).then(resolve, reject);
|
|
|
|
});
|
|
|
|
} else {
|
2019-10-15 21:13:33 +03:00
|
|
|
require(["metadataEditor"], function (metadataEditor) {
|
2019-01-10 15:39:37 +03:00
|
|
|
metadataEditor.show(item.Id, serverId).then(resolve, reject);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function deleteItem(apiClient, item) {
|
2019-01-10 15:39:37 +03:00
|
|
|
return new Promise(function (resolve, reject) {
|
2019-10-15 21:13:33 +03:00
|
|
|
require(["deleteHelper"], function (deleteHelper) {
|
2018-10-23 01:05:09 +03:00
|
|
|
deleteHelper.deleteItem({
|
|
|
|
item: item,
|
2019-01-10 15:39:37 +03:00
|
|
|
navigate: false
|
|
|
|
}).then(function () {
|
|
|
|
resolve(true);
|
|
|
|
}, reject);
|
|
|
|
});
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function refresh(apiClient, item) {
|
2019-10-15 21:13:33 +03:00
|
|
|
require(["refreshDialog"], function (refreshDialog) {
|
2018-10-23 01:05:09 +03:00
|
|
|
new refreshDialog({
|
|
|
|
itemIds: [item.Id],
|
|
|
|
serverId: apiClient.serverInfo().Id,
|
2019-10-15 21:13:33 +03:00
|
|
|
mode: item.Type === "CollectionFolder" ? "scan" : null
|
2019-01-10 15:39:37 +03:00
|
|
|
}).show();
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
function show(options) {
|
|
|
|
var commands = getCommands(options);
|
2019-01-10 15:39:37 +03:00
|
|
|
if (!commands.length) {
|
|
|
|
return Promise.reject();
|
|
|
|
}
|
|
|
|
|
|
|
|
return actionsheet.show({
|
2018-10-23 01:05:09 +03:00
|
|
|
items: commands,
|
|
|
|
positionTo: options.positionTo,
|
2019-10-15 21:13:33 +03:00
|
|
|
resolveOnClick: ["share"]
|
2019-01-10 15:39:37 +03:00
|
|
|
}).then(function (id) {
|
|
|
|
return executeCommand(options.item, id, options);
|
|
|
|
});
|
2018-10-23 01:05:09 +03:00
|
|
|
}
|
2019-01-10 15:39:37 +03:00
|
|
|
|
2018-10-23 01:05:09 +03:00
|
|
|
return {
|
|
|
|
getCommands: getCommands,
|
|
|
|
show: show
|
2019-01-10 15:39:37 +03:00
|
|
|
};
|
2019-08-19 12:35:57 +03:00
|
|
|
});
|