switch to shared play menu

This commit is contained in:
Luke Pulverenti 2016-07-17 16:30:14 -04:00
parent c56e87cd63
commit c925a314cf
2 changed files with 14 additions and 110 deletions

View File

@ -1984,27 +1984,31 @@
} }
} }
function showPlayMenu(item, target) {
require(['playMenu'], function (playMenu) {
playMenu.show({
item: item,
positionTo: target
});
});
}
function playCurrentItem(button) { function playCurrentItem(button) {
if (currentItem.Type == 'Program') { if (currentItem.Type == 'Program') {
ApiClient.getLiveTvChannel(currentItem.ChannelId, Dashboard.getCurrentUserId()).then(function (channel) { ApiClient.getLiveTvChannel(currentItem.ChannelId, Dashboard.getCurrentUserId()).then(function (channel) {
LibraryBrowser.showPlayMenu(null, channel.Id, channel.Type, false, channel.MediaType, (channel.UserData || {}).PlaybackPositionTicks); showPlayMenu(channel, button);
}); });
return; return;
} }
var userdata = currentItem.UserData || {}; showPlayMenu(currentItem, button);
var mediaType = currentItem.MediaType;
if (currentItem.Type == "MusicArtist" || currentItem.Type == "MusicAlbum") {
mediaType = "Audio";
}
LibraryBrowser.showPlayMenu(button, currentItem.Id, currentItem.Type, currentItem.IsFolder, mediaType, userdata.PlaybackPositionTicks);
} }
function deleteTimer(page, params, id) { function deleteTimer(page, params, id) {

View File

@ -577,106 +577,6 @@
}); });
}, },
showPlayMenu: function (positionTo, itemId, itemType, isFolder, mediaType, resumePositionTicks) {
var externalPlayers = AppInfo.supportsExternalPlayers && appSettings.enableExternalPlayers();
if (!resumePositionTicks && mediaType != "Audio" && !isFolder) {
if (!externalPlayers || mediaType != "Video") {
MediaController.play(itemId);
return;
}
}
var menuItems = [];
if (resumePositionTicks) {
menuItems.push({
name: Globalize.translate('ButtonResume'),
id: 'resume',
ironIcon: 'play-arrow'
});
}
menuItems.push({
name: Globalize.translate('ButtonPlay'),
id: 'play',
ironIcon: 'play-arrow'
});
if (!isFolder && externalPlayers && mediaType != "Audio") {
menuItems.push({
name: Globalize.translate('ButtonPlayExternalPlayer'),
id: 'externalplayer',
ironIcon: 'airplay'
});
}
if (MediaController.canQueueMediaType(mediaType, itemType)) {
menuItems.push({
name: Globalize.translate('ButtonQueue'),
id: 'queue',
ironIcon: 'playlist-add'
});
}
if (itemType == "Audio" || itemType == "MusicAlbum" || itemType == "MusicArtist" || itemType == "MusicGenre") {
menuItems.push({
name: Globalize.translate('ButtonInstantMix'),
id: 'instantmix',
ironIcon: 'shuffle'
});
}
if (isFolder || itemType == "MusicArtist" || itemType == "MusicGenre") {
menuItems.push({
name: Globalize.translate('ButtonShuffle'),
id: 'shuffle',
ironIcon: 'shuffle'
});
}
require(['actionsheet'], function (actionsheet) {
actionsheet.show({
items: menuItems,
positionTo: positionTo,
callback: function (id) {
switch (id) {
case 'play':
MediaController.play(itemId);
break;
case 'externalplayer':
LibraryBrowser.playInExternalPlayer(itemId);
break;
case 'resume':
MediaController.play({
ids: [itemId],
startPositionTicks: resumePositionTicks
});
break;
case 'queue':
MediaController.queue(itemId);
break;
case 'instantmix':
MediaController.instantMix(itemId);
break;
case 'shuffle':
MediaController.shuffle(itemId);
break;
default:
break;
}
}
});
});
},
deleteItems: function (itemIds) { deleteItems: function (itemIds) {
return new Promise(function (resolve, reject) { return new Promise(function (resolve, reject) {