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

@ -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;