2016-07-21 13:25:55 -07:00
|
|
|
define(['actionsheet', 'datetime', 'playbackManager', 'globalize', 'appSettings'], function (actionsheet, datetime, playbackManager, globalize, appSettings) {
|
2016-10-17 22:06:48 -07:00
|
|
|
'use strict';
|
2016-07-21 13:25:55 -07:00
|
|
|
|
|
|
|
var isMobileApp = window.Dashboard != null;
|
2016-07-17 13:08:04 -07:00
|
|
|
|
|
|
|
function show(options) {
|
|
|
|
|
|
|
|
var item = options.item;
|
|
|
|
|
|
|
|
var itemType = item.Type;
|
|
|
|
var mediaType = item.MediaType;
|
|
|
|
var isFolder = item.IsFolder;
|
|
|
|
var itemId = item.Id;
|
2016-07-23 11:10:22 -07:00
|
|
|
var channelId = item.ChannelId;
|
2016-07-17 13:08:04 -07:00
|
|
|
var serverId = item.ServerId;
|
|
|
|
var resumePositionTicks = item.UserData ? item.UserData.PlaybackPositionTicks : null;
|
|
|
|
|
2016-10-17 22:06:48 -07:00
|
|
|
var showExternalPlayer = isMobileApp && mediaType === 'Video' && !isFolder && appSettings.enableExternalPlayers();
|
|
|
|
var playableItemId = itemType === 'Program' ? channelId : itemId;
|
2016-07-23 11:10:22 -07:00
|
|
|
|
2016-10-17 22:06:48 -07:00
|
|
|
if (!resumePositionTicks && mediaType !== "Audio" && !isFolder && !showExternalPlayer) {
|
2016-07-28 19:42:42 -07:00
|
|
|
playbackManager.play({
|
|
|
|
ids: [playableItemId],
|
|
|
|
serverId: serverId
|
|
|
|
});
|
2016-07-17 13:08:04 -07:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuItems = [];
|
|
|
|
|
|
|
|
if (resumePositionTicks) {
|
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('sharedcomponents#ResumeAt', datetime.getDisplayRunningTime(resumePositionTicks)),
|
|
|
|
id: 'resume'
|
|
|
|
});
|
|
|
|
|
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('sharedcomponents#PlayFromBeginning'),
|
|
|
|
id: 'play'
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('sharedcomponents#Play'),
|
|
|
|
id: 'play'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-07-21 13:25:55 -07:00
|
|
|
if (showExternalPlayer) {
|
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('ButtonPlayExternalPlayer'),
|
|
|
|
id: 'externalplayer'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-08-06 19:11:39 -07:00
|
|
|
if (playbackManager.canQueue(item)) {
|
2016-07-17 13:08:04 -07:00
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('sharedcomponents#Queue'),
|
|
|
|
id: 'queue'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:06:48 -07:00
|
|
|
if (itemType === "Audio" || itemType === "MusicAlbum" || itemType === "MusicArtist" || itemType === "MusicGenre") {
|
2016-07-17 13:08:04 -07:00
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('sharedcomponents#InstantMix'),
|
|
|
|
id: 'instantmix'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-10-17 22:06:48 -07:00
|
|
|
if (isFolder || itemType === "MusicArtist" || itemType === "MusicGenre") {
|
2016-07-17 13:08:04 -07:00
|
|
|
menuItems.push({
|
|
|
|
name: globalize.translate('sharedcomponents#Shuffle'),
|
|
|
|
id: 'shuffle'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
actionsheet.show({
|
|
|
|
|
|
|
|
items: menuItems,
|
|
|
|
positionTo: options.positionTo
|
|
|
|
|
|
|
|
}).then(function (id) {
|
|
|
|
switch (id) {
|
|
|
|
|
|
|
|
case 'play':
|
|
|
|
playbackManager.play({
|
2016-07-23 11:10:22 -07:00
|
|
|
ids: [playableItemId],
|
|
|
|
serverId: serverId
|
2016-07-17 13:08:04 -07:00
|
|
|
});
|
|
|
|
break;
|
2016-07-21 13:25:55 -07:00
|
|
|
case 'externalplayer':
|
2016-07-23 11:10:22 -07:00
|
|
|
LibraryBrowser.playInExternalPlayer(playableItemId);
|
2016-07-21 13:25:55 -07:00
|
|
|
break;
|
2016-07-17 13:08:04 -07:00
|
|
|
case 'resume':
|
|
|
|
playbackManager.play({
|
2016-07-23 11:10:22 -07:00
|
|
|
ids: [playableItemId],
|
2016-07-17 13:08:04 -07:00
|
|
|
startPositionTicks: resumePositionTicks,
|
2016-07-23 11:10:22 -07:00
|
|
|
serverId: serverId
|
2016-07-17 13:08:04 -07:00
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 'queue':
|
|
|
|
playbackManager.queue(item);
|
|
|
|
break;
|
|
|
|
case 'instantmix':
|
|
|
|
playbackManager.instantMix(item);
|
|
|
|
break;
|
|
|
|
case 'shuffle':
|
|
|
|
playbackManager.shuffle(item);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
show: show
|
|
|
|
};
|
|
|
|
});
|