jellyfin-web/dashboard-ui/bower_components/emby-webcomponents/playmenu.js

75 lines
2.1 KiB
JavaScript
Raw Normal View History

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
2016-07-17 13:08:04 -07:00
function show(options) {
var item = options.item;
var itemType = item.Type;
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 playableItemId = itemType === 'Program' ? channelId : itemId;
2016-07-23 11:10:22 -07:00
2017-01-18 12:53:10 -07:00
if (!resumePositionTicks || isFolder) {
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 = [];
2017-01-20 10:52:37 -07:00
menuItems.push({
name: globalize.translate('sharedcomponents#ResumeAt', datetime.getDisplayRunningTime(resumePositionTicks)),
id: 'resume'
});
2016-07-17 13:08:04 -07:00
2017-01-20 10:52:37 -07:00
menuItems.push({
name: globalize.translate('sharedcomponents#PlayFromBeginning'),
id: 'play'
});
2016-07-17 13:08:04 -07:00
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;
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':
2017-01-01 15:34:44 -07:00
playbackManager.queue({
items: [item]
});
2016-07-17 13:08:04 -07:00
break;
case 'shuffle':
playbackManager.shuffle(item);
break;
default:
break;
}
});
}
return {
show: show
};
});