update now playing screen

This commit is contained in:
Luke Pulverenti 2017-01-20 12:52:37 -05:00
parent 668418e69b
commit 4589e01159
22 changed files with 245 additions and 97 deletions

View File

@ -16,12 +16,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.1.118",
"_release": "1.1.118",
"version": "1.1.119",
"_release": "1.1.119",
"_resolution": {
"type": "version",
"tag": "1.1.118",
"commit": "e43c750bd0a2cdb109e4b12ae561960118381e51"
"tag": "1.1.119",
"commit": "d3d62a7f416a3b980bf98000830d2ee6203a1658"
},
"_source": "https://github.com/MediaBrowser/Emby.ApiClient.Javascript.git",
"_target": "^1.1.51",

View File

@ -2123,6 +2123,19 @@
return self.getJSON(url);
};
self.getItemDownloadUrl = function (itemId) {
if (!itemId) {
throw new Error("itemId cannot be empty");
}
var url = "Items/" + itemId + "/Download";
return self.getUrl(url, {
api_key: self.accessToken()
});
};
self.getSessions = function (options) {
var url = self.getUrl("Sessions", options);

View File

@ -216,7 +216,7 @@
return connectUser;
};
var minServerVersion = '3.0.8000';
var minServerVersion = '3.0.8500';
self.minServerVersion = function (val) {
if (val) {

View File

@ -203,7 +203,14 @@
}
function addOrUpdateLocalItem(localItem) {
return itemrepository.set(localItem.Id, localItem);
console.log('addOrUpdateLocalItem Start');
return itemrepository.set(localItem.Id, localItem).then(function (res) {
console.log('addOrUpdateLocalItem Success');
return Promise.resolve(true);
}, function (error) {
console.log('addOrUpdateLocalItem Error');
return Promise.resolve(false);
});
}
function createLocalItem(libraryItem, serverInfo, jobItem) {
@ -342,6 +349,11 @@
return transfermanager.isDownloadFileInQueue(path);
}
function getDownloadItemCount() {
return transfermanager.getDownloadItemCount();
}
function translateFilePath(path) {
return Promise.resolve(path);
}
@ -471,6 +483,7 @@
getServerItems: getServerItems,
getItemFileSize: getItemFileSize,
isDownloadFileInQueue: isDownloadFileInQueue,
getDownloadItemCount: getDownloadItemCount,
getViews: getViews,
getViewItems: getViewItems,
resyncTransfers: resyncTransfers

View File

@ -90,7 +90,7 @@
function clear() {
return dbPromise.then(function (db) {
var tx = db.transaction(dbName, 'readwrite');
tx.objectStore(dbName).clear(key);
tx.objectStore(dbName).clear();
return tx.complete;
});
}

View File

@ -178,7 +178,7 @@
});
}
function getNewMedia(apiClient, serverInfo, options) {
function getNewMedia(apiClient, serverInfo, options, downloadCount) {
console.log('[mediasync] Begin getNewMedia');
@ -186,10 +186,15 @@
var p = Promise.resolve();
var maxDownloads = 10;
var currentCount = downloadCount;
jobItems.forEach(function (jobItem) {
p = p.then(function () {
return getNewItem(jobItem, apiClient, serverInfo, options);
});
if (currentCount++ <= maxDownloads) {
p = p.then(function () {
return getNewItem(jobItem, apiClient, serverInfo, options);
});
}
});
return p.then(function () {
@ -344,6 +349,7 @@
return localassetmanager.addOrUpdateLocalItem(localItem);
}, function (err) {
console.log('[mediasync] Error getImages: ' + err.toString());
return Promise.resolve();
});
}
@ -368,9 +374,15 @@
console.log('[mediasync] downloadImage ' + itemId + ' ' + imageType + '_' + index.toString());
return localassetmanager.downloadImage(localItem, imageUrl, serverId, itemId, imageType, index);
return localassetmanager.downloadImage(localItem, imageUrl, serverId, itemId, imageType, index).then(function (result) {
return Promise.resolve();
}, function (err) {
console.log('[mediasync] Error downloadImage: ' + err.toString());
return Promise.resolve();
});
}, function (err) {
console.log('[mediasync] Error downloadImage: ' + err.toString());
return Promise.resolve();
});
}
@ -450,26 +462,28 @@
return processDownloadStatus(apiClient, serverInfo, options).then(function () {
if (options.syncCheckProgressOnly === true) {
return Promise.resolve();
}
return localassetmanager.getDownloadItemCount().then(function (downloadCount) {
return reportOfflineActions(apiClient, serverInfo).then(function () {
if (options.syncCheckProgressOnly === true && downloadCount > 2) {
return Promise.resolve();
}
//// Do the first data sync
//return syncData(apiClient, serverInfo, false).then(function () {
return reportOfflineActions(apiClient, serverInfo).then(function () {
// Download new content
return getNewMedia(apiClient, serverInfo, options).then(function () {
// Download new content
return getNewMedia(apiClient, serverInfo, options, downloadCount).then(function () {
// Do the second data sync
return syncData(apiClient, serverInfo, false).then(function () {
console.log('[mediasync]************************************* Exit sync');
return Promise.resolve();
// Do the second data sync
return syncData(apiClient, serverInfo, false).then(function () {
console.log('[mediasync]************************************* Exit sync');
return Promise.resolve();
});
});
//});
});
//});
});
}, function (err) {
console.error(err.toString());
});
};
};

View File

@ -14,12 +14,12 @@
},
"devDependencies": {},
"ignore": [],
"version": "1.4.478",
"_release": "1.4.478",
"version": "1.4.479",
"_release": "1.4.479",
"_resolution": {
"type": "version",
"tag": "1.4.478",
"commit": "f0d0c518404756700c0d9f709c79f00fd45f06b0"
"tag": "1.4.479",
"commit": "b01a4ecb86439ba61593ff9d28721c0af048c4ef"
},
"_source": "https://github.com/MediaBrowser/emby-webcomponents.git",
"_target": "^1.2.1",

View File

@ -251,6 +251,11 @@
}
}
ItemsContainerProtoType.createdCallback = function () {
this.classList.add('itemsContainer');
};
ItemsContainerProtoType.attachedCallback = function () {
this.addEventListener('click', onClick);
@ -278,6 +283,10 @@
addNotificationEvent(this, 'SeriesTimerCreated', onSeriesTimerCreated);
addNotificationEvent(this, 'TimerCancelled', onTimerCancelled);
addNotificationEvent(this, 'SeriesTimerCancelled', onSeriesTimerCancelled);
if (this.getAttribute('data-dragreorder') === 'true') {
this.enableDragReordering(true);
}
};
ItemsContainerProtoType.detachedCallback = function () {

View File

@ -171,9 +171,7 @@ define(['events', 'browser', 'pluginManager', 'apphost', 'appSettings'], functio
var originalVolume = elem.volume;
return fade(elem, function () {
}).then(function () {
return fade(elem, elem.volume).then(function () {
if (!elem.paused) {
elem.pause();
}
@ -194,13 +192,16 @@ define(['events', 'browser', 'pluginManager', 'apphost', 'appSettings'], functio
var fadeTimeout;
function fade(elem) {
function fade(elem, startingVolume) {
var newVolume = Math.max(0, elem.volume - 0.15);
// Need to record the starting volume on each pass rather than querying elem.volume
// This is due to iOS safari not allowing volume changes and always returning the system volume value
var newVolume = Math.max(0, startingVolume - 0.15);
console.log('fading volume to ' + newVolume);
elem.volume = newVolume;
if (!elem.volume) {
if (newVolume <= 0) {
return Promise.resolve();
}
@ -209,7 +210,7 @@ define(['events', 'browser', 'pluginManager', 'apphost', 'appSettings'], functio
cancelFadeTimeout();
fadeTimeout = setTimeout(function () {
fade(elem).then(resolve, reject);
fade(elem, newVolume).then(resolve, reject);
}, 100);
});
}

View File

@ -295,9 +295,7 @@ define(['apphost', 'globalize', 'connectionManager', 'itemHelper', 'embyRouter',
case 'download':
{
require(['fileDownloader'], function (fileDownloader) {
var downloadHref = apiClient.getUrl("Items/" + itemId + "/Download", {
api_key: apiClient.accessToken()
});
var downloadHref = apiClient.getItemDownloadUrl(itemId);
fileDownloader.download([
{

View File

@ -2117,6 +2117,23 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
});
}
function isHostReachable(mediaSource, apiClient) {
var url = mediaSource.Path;
var isServerAddress = url.toLowerCase().replace('https:', 'http').indexOf(apiClient.serverAddress().toLowerCase().replace('https:', 'http').substring(0, 14)) === 0;
if (isServerAddress) {
return Promise.resolve();
}
if (mediaSource.IsRemote) {
return Promise.resolve();
}
return Promise.reject();
}
function supportsDirectPlay(apiClient, mediaSource) {
return new Promise(function (resolve, reject) {
@ -2130,12 +2147,15 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
resolve(true);
}
else {
var val = mediaSource.Path.toLowerCase().replace('https:', 'http').indexOf(apiClient.serverAddress().toLowerCase().replace('https:', 'http').substring(0, 14)) === 0;
resolve(val);
isHostReachable(mediaSource, apiClient).then(function () {
resolve(true);
}, function () {
resolve(false);
});
}
}
if (mediaSource.Protocol === 'File') {
else if (mediaSource.Protocol === 'File') {
// Determine if the file can be accessed directly
require(['filesystem'], function (filesystem) {
@ -2241,7 +2261,7 @@ define(['events', 'datetime', 'appSettings', 'pluginManager', 'userSettings', 'g
}
function findPlaylistIndex(playlistItemId, list) {
for (var i = 0, length = playlist.length; i < length; i++) {
if (list[i].PlaylistItemId === playlistItemId) {
return i;

View File

@ -1,4 +1,4 @@
define(['appSettings', 'events', 'browser', 'loading', 'playbackManager', 'embyRouter', 'globalize'], function (appSettings, events, browser, loading, playbackManager, embyRouter, globalize) {
define(['appSettings', 'events', 'browser', 'loading', 'playbackManager', 'embyRouter', 'globalize', 'apphost'], function (appSettings, events, browser, loading, playbackManager, embyRouter, globalize, appHost) {
'use strict';
var currentDisplayInfo;
@ -79,7 +79,7 @@
// Unfortunately we can't allow the url to change or chromecast will throw a security error
// Might be able to solve this in the future by moving the dialogs to hashbangs
if (!((!browser.chrome) || AppInfo.isNativeApp)) {
if (!(!browser.chrome || appHost.supports('castmenuhashchange'))) {
menuOptions.enableHistory = false;
}

View File

@ -6,7 +6,6 @@ define(['actionsheet', 'datetime', 'playbackManager', 'globalize', 'appSettings'
var item = options.item;
var itemType = item.Type;
var mediaType = item.MediaType;
var isFolder = item.IsFolder;
var itemId = item.Id;
var channelId = item.ChannelId;
@ -25,29 +24,15 @@ define(['actionsheet', 'datetime', 'playbackManager', 'globalize', 'appSettings'
var menuItems = [];
if (resumePositionTicks) {
menuItems.push({
name: globalize.translate('sharedcomponents#ResumeAt', datetime.getDisplayRunningTime(resumePositionTicks)),
id: 'resume'
});
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'
});
}
if (isFolder || itemType === "MusicArtist" || itemType === "MusicGenre") {
menuItems.push({
name: globalize.translate('sharedcomponents#Shuffle'),
id: 'shuffle'
});
}
menuItems.push({
name: globalize.translate('sharedcomponents#PlayFromBeginning'),
id: 'play'
});
actionsheet.show({

View File

@ -0,0 +1,100 @@
// From https://github.com/parshap/node-sanitize-filename
define([], function () {
'use strict';
var illegalRe = /[\/\?<>\\:\*\|":]/g;
var controlRe = /[\x00-\x1f\x80-\x9f]/g;
var reservedRe = /^\.+$/;
var windowsReservedRe = /^(con|prn|aux|nul|com[0-9]|lpt[0-9])(\..*)?$/i;
var windowsTrailingRe = /[\. ]+$/;
function isHighSurrogate(codePoint) {
return codePoint >= 0xd800 && codePoint <= 0xdbff;
}
function isLowSurrogate(codePoint) {
return codePoint >= 0xdc00 && codePoint <= 0xdfff;
}
function getByteLength(string) {
if (typeof string !== "string") {
throw new Error("Input must be string");
}
var charLength = string.length;
var byteLength = 0;
var codePoint = null;
var prevCodePoint = null;
for (var i = 0; i < charLength; i++) {
codePoint = string.charCodeAt(i);
// handle 4-byte non-BMP chars
// low surrogate
if (isLowSurrogate(codePoint)) {
// when parsing previous hi-surrogate, 3 is added to byteLength
if (prevCodePoint != null && isHighSurrogate(prevCodePoint)) {
byteLength += 1;
}
else {
byteLength += 3;
}
}
else if (codePoint <= 0x7f) {
byteLength += 1;
}
else if (codePoint >= 0x80 && codePoint <= 0x7ff) {
byteLength += 2;
}
else if (codePoint >= 0x800 && codePoint <= 0xffff) {
byteLength += 3;
}
prevCodePoint = codePoint;
}
return byteLength;
};
function truncate(string, byteLength) {
if (typeof string !== "string") {
throw new Error("Input must be string");
}
var charLength = string.length;
var curByteLength = 0;
var codePoint;
var segment;
for (var i = 0; i < charLength; i += 1) {
codePoint = string.charCodeAt(i);
segment = string[i];
if (isHighSurrogate(codePoint) && isLowSurrogate(string.charCodeAt(i + 1))) {
i += 1;
segment += string[i];
}
curByteLength += getByteLength(segment);
if (curByteLength === byteLength) {
return string.slice(0, i + 1);
}
else if (curByteLength > byteLength) {
return string.slice(0, i - segment.length + 1);
}
}
return string;
};
return {
sanitize: function (input, replacement) {
var sanitized = input
.replace(illegalRe, replacement)
.replace(controlRe, replacement)
.replace(reservedRe, replacement)
.replace(windowsReservedRe, replacement)
.replace(windowsTrailingRe, replacement);
return truncate(sanitized, 255);
}
};
});

View File

@ -59,9 +59,7 @@ define(['dialogHelper', 'inputManager', 'connectionManager', 'layoutManager', 'f
} else {
if (item.MediaType === 'Photo' && original) {
return apiClient.getUrl("Items/" + item.Id + "/Download", {
api_key: apiClient.accessToken()
});
return apiClient.getItemDownloadUrl(item.Id);
}
imageOptions.type = "Primary";
return getImageUrl(item, imageOptions, apiClient);

View File

@ -106,9 +106,9 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
if (item.MediaType === 'Video' || item.Type === 'Series' || item.Type === 'Season' || item.Type === 'BoxSet' || item.Type === 'Playlist') {
if (item.Type !== 'TvChannel') {
if (userData.Played) {
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass + ' btnUserDataOn', iconCssClass, 'check', tooltipPlayed, style);
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass + ' btnUserDataOn', iconCssClass, '&#xE5CA;', tooltipPlayed, style);
} else {
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass, iconCssClass, 'check', tooltipPlayed, style);
html += getUserDataButtonHtml('markPlayed', itemId, serverId, btnCssClass, iconCssClass, '&#xE5CA;', tooltipPlayed, style);
}
}
}
@ -133,9 +133,9 @@ define(['connectionManager', 'globalize', 'dom', 'itemHelper', 'paper-icon-butto
var tooltipFavorite = globalize.translate('sharedcomponents#Favorite');
if (userData.IsFavorite) {
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData btnUserDataOn', iconCssClass, 'favorite', tooltipFavorite, style);
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData btnUserDataOn', iconCssClass, '&#xE87D;', tooltipFavorite, style);
} else {
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData', iconCssClass, 'favorite', tooltipFavorite, style);
html += getUserDataButtonHtml('markFavorite', itemId, serverId, btnCssClass + ' btnUserData', iconCssClass, '&#xE87D;', tooltipFavorite, style);
}
return html;

View File

@ -1,4 +1,4 @@
define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'userdataButtons', 'imageLoader', 'playbackManager', 'nowPlayingHelper', 'events', 'connectionManager', 'apphost', 'globalize', 'cardStyle'], function (browser, datetime, backdrop, libraryBrowser, listView, userdataButtons, imageLoader, playbackManager, nowPlayingHelper, events, connectionManager, appHost, globalize) {
define(['browser', 'datetime', 'backdrop', 'libraryBrowser', 'listView', 'userdataButtons', 'imageLoader', 'playbackManager', 'nowPlayingHelper', 'events', 'connectionManager', 'apphost', 'globalize', 'cardStyle', 'emby-itemscontainer', 'css!css/nowplaying.css'], function (browser, datetime, backdrop, libraryBrowser, listView, userdataButtons, imageLoader, playbackManager, nowPlayingHelper, events, connectionManager, appHost, globalize) {
'use strict';
function showSlideshowMenu(context) {
@ -800,8 +800,6 @@
playbackManager.movePlaylistItem(playlistItemId, newIndex, currentPlayer);
});
playlistContainer.enableDragReordering(true);
}
function onPlayerChange() {
@ -860,7 +858,6 @@
function init(ownerView, context) {
require(['css!css/nowplaying.css']);
bindEvents(context);
context.querySelector('.sendMessageForm').addEventListener('submit', onMessageSubmit);

View File

@ -33,8 +33,9 @@
}
}
.mediaButton img {
height: 24px;
.nowPlayingBarInfoContainer {
display: flex;
align-items: center;
}
.currentTime {
@ -111,13 +112,13 @@
}
.nowPlayingBarText {
display: inline-block;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
vertical-align: middle;
text-align: left;
max-width: 130px;
flex-grow: 1;
}
.repeatActive {

View File

@ -162,7 +162,7 @@
<br />
<div>
<h1>${TabPlaylist}</h1>
<div class="playlist itemsContainer vertical-list" is="emby-itemscontainer">
<div class="playlist itemsContainer vertical-list" is="emby-itemscontainer" data-dragreorder="true">
</div>
</div>
<br />

View File

@ -120,13 +120,6 @@
query.ParentId = LibraryMenu.getTopParentId();
var page = this;
var limit = LibraryBrowser.getDefaultPageSize();
// If the default page size has changed, the start index will have to be reset
if (limit != query.Limit) {
query.Limit = limit;
query.StartIndex = 0;
}
if (params.IsMovie == 'true') {
query.IsMovie = true;

View File

@ -1570,7 +1570,10 @@ var AppInfo = {};
document.title = Globalize.translateDocument(document.title, 'core');
loadPlugins([], browserInfo).then(onAppReady);
require(['apphost'], function (appHost) {
loadPlugins([], appHost, browserInfo).then(onAppReady);
});
}
function defineRoute(newRoute, dictionary) {
@ -2368,7 +2371,7 @@ var AppInfo = {};
});
}
function loadPlugins(externalPlugins, browser, shell) {
function loadPlugins(externalPlugins, appHost, browser, shell) {
console.log('Loading installed plugins');
@ -2413,10 +2416,13 @@ var AppInfo = {};
}
list.push('bower_components/emby-webcomponents/htmlvideoplayer/plugin');
list.push('bower_components/emby-webcomponents/sessionplayer');
if (browser.chrome) {
list.push('bower_components/emby-webcomponents/chromecastplayer');
if (appHost.supports('remotecontrol')) {
list.push('bower_components/emby-webcomponents/sessionplayer');
if (browser.chrome) {
list.push('bower_components/emby-webcomponents/chromecastplayer');
}
}
list.push('bower_components/emby-webcomponents/youtubeplayer/plugin');

View File

@ -1,4 +1,4 @@
define(['playbackManager', 'dom', 'inputmanager', 'datetime', 'itemHelper', 'mediaInfo', 'focusManager', 'imageLoader', 'scrollHelper', 'events', 'connectionManager', 'browser', 'globalize', 'apphost', 'scrollStyles', 'emby-slider'], function (playbackManager, dom, inputManager, datetime, itemHelper, mediaInfo, focusManager, imageLoader, scrollHelper, events, connectionManager, browser, globalize, appHost) {
define(['playbackManager', 'dom', 'inputmanager', 'datetime', 'itemHelper', 'mediaInfo', 'focusManager', 'imageLoader', 'scrollHelper', 'events', 'connectionManager', 'browser', 'globalize', 'apphost', 'layoutManager', 'scrollStyles', 'emby-slider'], function (playbackManager, dom, inputManager, datetime, itemHelper, mediaInfo, focusManager, imageLoader, scrollHelper, events, connectionManager, browser, globalize, appHost, layoutManager) {
'use strict';
function seriesImageUrl(item, options) {
@ -425,7 +425,7 @@
releaseCurrentPlayer();
});
if (appHost.supports('remotecontrol')) {
if (appHost.supports('remotecontrol') && !layoutManager.tv) {
view.querySelector('.btnCast').classList.remove('hide');
}