mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update client sync
This commit is contained in:
parent
0db16cad5a
commit
8bf9a6f51e
12 changed files with 133 additions and 206 deletions
|
@ -95,6 +95,13 @@
|
|||
return deferred.promise();
|
||||
}
|
||||
|
||||
function fileExists(path) {
|
||||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
deferred.resolveWith(null, [false]);
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
window.LocalAssetManager = {
|
||||
getLocalMediaSource: getLocalMediaSource,
|
||||
saveOfflineUser: saveOfflineUser,
|
||||
|
@ -110,7 +117,8 @@
|
|||
downloadFile: downloadFile,
|
||||
downloadSubtitles: downloadSubtitles,
|
||||
hasImage: hasImage,
|
||||
downloadImage: downloadImage
|
||||
downloadImage: downloadImage,
|
||||
fileExists: fileExists
|
||||
};
|
||||
|
||||
})();
|
14
dashboard-ui/cordova/android/filesystem.js
vendored
14
dashboard-ui/cordova/android/filesystem.js
vendored
|
@ -1,14 +0,0 @@
|
|||
(function () {
|
||||
|
||||
window.FileSystemBridge = {
|
||||
|
||||
fileExists: function (path) {
|
||||
return NativeFileSystem.fileExists(path);
|
||||
},
|
||||
|
||||
translateFilePath: function (path) {
|
||||
return 'file://' + NativeFileSystem.translateFilePath(path);
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
14
dashboard-ui/cordova/filesystem.js
vendored
14
dashboard-ui/cordova/filesystem.js
vendored
|
@ -1,14 +0,0 @@
|
|||
(function () {
|
||||
|
||||
window.FileSystemBridge = {
|
||||
|
||||
fileExists: function (path) {
|
||||
return false;
|
||||
},
|
||||
|
||||
translateFilePath: function (path) {
|
||||
return 'file://' + path;
|
||||
}
|
||||
};
|
||||
|
||||
})();
|
45
dashboard-ui/cordova/localassetmanager.js
vendored
45
dashboard-ui/cordova/localassetmanager.js
vendored
|
@ -19,9 +19,9 @@
|
|||
|
||||
getLocalItem(itemId, serverId).done(function (localItem) {
|
||||
|
||||
if (localItem && localItem.MediaSources.length) {
|
||||
if (localItem && localItem.Item.MediaSources.length) {
|
||||
|
||||
var mediaSource = localItem.MediaSources[0];
|
||||
var mediaSource = localItem.Item.MediaSources[0];
|
||||
|
||||
fileExists(mediaSource.Path).done(function (exists) {
|
||||
|
||||
|
@ -156,11 +156,11 @@
|
|||
|
||||
db.transaction(function (tx) {
|
||||
|
||||
tx.executeSql("SELECT json from offlineactions where ServerId=?", [serverId], function (tx, res) {
|
||||
tx.executeSql("SELECT Json from offlineactions where ServerId=?", [serverId], function (tx, res) {
|
||||
|
||||
var actions = [];
|
||||
for (var i = 0, length = res.rows.length; i < length; i++) {
|
||||
actions.push(JSON.parse(res.rows.item(i).json));
|
||||
actions.push(JSON.parse(res.rows.item(i).Json));
|
||||
}
|
||||
|
||||
deferred.resolveWith(null, [actions]);
|
||||
|
@ -260,7 +260,7 @@
|
|||
|
||||
var localItem = JSON.parse(res.rows.item(0).Json);
|
||||
|
||||
deferred.resolveWith(null, [item]);
|
||||
deferred.resolveWith(null, [localItem]);
|
||||
}
|
||||
else {
|
||||
deferred.resolveWith(null, [null]);
|
||||
|
@ -350,7 +350,7 @@
|
|||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
Logger.log('Deleting ' + path);
|
||||
resolveLocalFileSystemURL(path, function (fileEntry) {
|
||||
resolveFile(path, function (fileEntry) {
|
||||
|
||||
fileEntry.remove(function () {
|
||||
Logger.log('Deleted ' + path);
|
||||
|
@ -370,6 +370,14 @@
|
|||
return deferred.promise();
|
||||
}
|
||||
|
||||
function resolveFile(path, success, fail) {
|
||||
|
||||
getFileSystem().done(function (fileSystem) {
|
||||
|
||||
fileSystem.root.getFile(path, { create: false }, success, fail);
|
||||
});
|
||||
}
|
||||
|
||||
function createLocalItem(libraryItem, serverInfo, originalFileName) {
|
||||
|
||||
var path = getDirectoryPath(libraryItem, serverInfo);
|
||||
|
@ -379,9 +387,7 @@
|
|||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
getFileSystem().done(function (fileSystem) {
|
||||
|
||||
var localPath = fileSystem.root.toURL() + "/" + path.join('/');
|
||||
var localPath = path.join('/');
|
||||
|
||||
item.LocalPath = localPath;
|
||||
|
||||
|
@ -397,7 +403,6 @@
|
|||
item.ItemId = libraryItem.Id;
|
||||
item.Id = getLocalId(item.ServerId, item.ItemId);
|
||||
deferred.resolveWith(null, [item]);
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
@ -405,7 +410,6 @@
|
|||
function getDirectoryPath(item, server) {
|
||||
|
||||
var parts = [];
|
||||
parts.push("emby");
|
||||
parts.push("sync");
|
||||
parts.push(server.Name);
|
||||
|
||||
|
@ -463,11 +467,11 @@
|
|||
|
||||
getFileSystem().done(function (fileSystem) {
|
||||
|
||||
var targetFile = localPath;
|
||||
fileSystem.root.getFile(fileName, { create: true }, function (targetFile) {
|
||||
|
||||
var downloader = new BackgroundTransfer.BackgroundDownloader();
|
||||
// Create a new download operation.
|
||||
var download = downloader.createDownload(url, targetFile);
|
||||
var download = downloader.createDownload(url, targetFile.toURL());
|
||||
// Start the download and persist the promise to be able to cancel the download.
|
||||
var downloadPromise = download.startAsync().then(function () {
|
||||
|
||||
|
@ -489,7 +493,7 @@
|
|||
Logger.log('download progress: ' + value);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
|
@ -589,11 +593,9 @@
|
|||
function getImageLocalPath(serverId, itemId, imageTag) {
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
getFileSystem().done(function (fileSystem) {
|
||||
var path = fileSystem.root.toURL() + "/emby/images/" + serverId + "/" + itemId + "/" + imageTag;
|
||||
var path = "images/" + serverId + "-" + itemId + "/" + imageTag;
|
||||
|
||||
deferred.resolveWith(null, [path]);
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
@ -602,12 +604,12 @@
|
|||
|
||||
var deferred = DeferredBuilder.Deferred();
|
||||
|
||||
resolveLocalFileSystemURL(path, function (fileEntry) {
|
||||
|
||||
resolveFile(path, function (fileEntry) {
|
||||
Logger.log('fileExists: true - path: ' + path);
|
||||
deferred.resolveWith(null, [true]);
|
||||
|
||||
}, function () {
|
||||
|
||||
Logger.log('fileExists: false - path: ' + path);
|
||||
deferred.resolveWith(null, [false]);
|
||||
});
|
||||
|
||||
|
@ -653,7 +655,8 @@
|
|||
downloadFile: downloadFile,
|
||||
downloadSubtitles: downloadSubtitles,
|
||||
hasImage: hasImage,
|
||||
downloadImage: downloadImage
|
||||
downloadImage: downloadImage,
|
||||
fileExists: fileExists
|
||||
};
|
||||
|
||||
})();
|
|
@ -207,7 +207,7 @@
|
|||
}
|
||||
|
||||
.viewMenuBar.semiTransparent {
|
||||
background-color: rgba(18, 18, 18, .70);
|
||||
background-color: rgba(18, 18, 18, .65);
|
||||
}
|
||||
|
||||
.paperLibraryViewNav {
|
||||
|
|
|
@ -104,40 +104,6 @@
|
|||
return profile;
|
||||
}
|
||||
|
||||
function validatePlaybackInfoResult(result) {
|
||||
|
||||
if (result.ErrorCode) {
|
||||
|
||||
MediaController.showPlaybackInfoErrorMessage(result.ErrorCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function getOptimalMediaSource(mediaType, versions) {
|
||||
|
||||
var optimalVersion = versions.filter(function (v) {
|
||||
|
||||
v.enableDirectPlay = MediaController.supportsDirectPlay(v);
|
||||
|
||||
return v.enableDirectPlay;
|
||||
|
||||
})[0];
|
||||
|
||||
if (!optimalVersion) {
|
||||
optimalVersion = versions.filter(function (v) {
|
||||
|
||||
return v.SupportsDirectStream;
|
||||
|
||||
})[0];
|
||||
}
|
||||
|
||||
return optimalVersion || versions.filter(function (s) {
|
||||
return s.SupportsTranscoding;
|
||||
})[0];
|
||||
}
|
||||
|
||||
var currentMediaSource;
|
||||
var currentItem;
|
||||
var basePlayerState;
|
||||
|
@ -146,37 +112,13 @@
|
|||
function getVideoStreamInfo(item) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
Dashboard.showModalLoadingMsg();
|
||||
|
||||
var deviceProfile = getDeviceProfile();
|
||||
var startPosition = 0;
|
||||
|
||||
MediaController.getPlaybackInfo(item.Id, deviceProfile, startPosition).done(function (playbackInfoResult) {
|
||||
MediaPlayer.tryStartPlayback(deviceProfile, item, startPosition, function (mediaSource) {
|
||||
|
||||
if (validatePlaybackInfoResult(playbackInfoResult)) {
|
||||
|
||||
var mediaSource = getOptimalMediaSource(item.MediaType, playbackInfoResult.MediaSources);
|
||||
|
||||
if (mediaSource) {
|
||||
|
||||
if (mediaSource.RequiresOpening) {
|
||||
|
||||
MediaController.getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) {
|
||||
|
||||
openLiveStreamResult.MediaSource.enableDirectPlay = MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource);
|
||||
|
||||
playInternalPostMediaSourceSelection(item, openLiveStreamResult.MediaSource, startPosition, deferred);
|
||||
});
|
||||
|
||||
} else {
|
||||
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, deferred);
|
||||
}
|
||||
} else {
|
||||
Dashboard.hideModalLoadingMsg();
|
||||
MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
|
|
|
@ -852,27 +852,36 @@
|
|||
|
||||
self.supportsDirectPlay = function (mediaSource) {
|
||||
|
||||
var deferred = $.Deferred();
|
||||
if (mediaSource.SupportsDirectPlay) {
|
||||
|
||||
if (mediaSource.Protocol == 'Http' && !mediaSource.RequiredHttpHeaders.length) {
|
||||
|
||||
// If this is the only way it can be played, then allow it
|
||||
if (!mediaSource.SupportsDirectStream && !mediaSource.SupportsTranscoding) {
|
||||
return true;
|
||||
deferred.resolveWith(null, [true]);
|
||||
}
|
||||
else {
|
||||
var val = mediaSource.Path.toLowerCase().replace('https:', 'http').indexOf(ApiClient.serverAddress().toLowerCase().replace('https:', 'http').substring(0, 14)) == 0;
|
||||
deferred.resolveWith(null, [val]);
|
||||
}
|
||||
|
||||
return mediaSource.Path.toLowerCase().replace('https:', 'http').indexOf(ApiClient.serverAddress().toLowerCase().replace('https:', 'http').substring(0, 14)) == 0;
|
||||
}
|
||||
|
||||
if (mediaSource.Protocol == 'File') {
|
||||
|
||||
var exists = FileSystemBridge.fileExists(mediaSource.Path);
|
||||
Logger.log('FileSystemBridge.fileExists: path: ' + mediaSource.Path + ' result: ' + exists);
|
||||
return exists;
|
||||
}
|
||||
}
|
||||
require(['localassetmanager'], function () {
|
||||
|
||||
return false;
|
||||
LocalAssetManager.fileExists(mediaSource.Path).done(function (exists) {
|
||||
Logger.log('LocalAssetManager.fileExists: path: ' + mediaSource.Path + ' result: ' + exists);
|
||||
deferred.resolveWith(null, [exists]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
deferred.resolveWith(null, [false]);
|
||||
}
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
self.showPlayerSelection = showPlayerSelection;
|
||||
|
|
|
@ -878,9 +878,18 @@
|
|||
|
||||
function getOptimalMediaSource(mediaType, versions) {
|
||||
|
||||
var optimalVersion = versions.filter(function (v) {
|
||||
var deferred = $.Deferred();
|
||||
|
||||
v.enableDirectPlay = MediaController.supportsDirectPlay(v);
|
||||
var promises = versions.map(function (v) {
|
||||
return MediaController.supportsDirectPlay(v);
|
||||
});
|
||||
|
||||
$.when.apply($, promises).done(function () {
|
||||
|
||||
for (var i = 0, length = versions.length; i < length; i++) {
|
||||
versions[i].enableDirectPlay = arguments[i] || false;
|
||||
}
|
||||
var optimalVersion = versions.filter(function (v) {
|
||||
|
||||
return v.enableDirectPlay;
|
||||
|
||||
|
@ -894,9 +903,14 @@
|
|||
})[0];
|
||||
}
|
||||
|
||||
return optimalVersion || versions.filter(function (s) {
|
||||
optimalVersion = optimalVersion || versions.filter(function (s) {
|
||||
return s.SupportsTranscoding;
|
||||
})[0];
|
||||
|
||||
deferred.resolveWith(null, [optimalVersion]);
|
||||
});
|
||||
|
||||
return deferred.promise();
|
||||
}
|
||||
|
||||
self.createStreamInfo = function (type, item, mediaSource, startPosition) {
|
||||
|
@ -916,10 +930,6 @@
|
|||
if (mediaSource.enableDirectPlay) {
|
||||
mediaUrl = mediaSource.Path;
|
||||
|
||||
if (mediaSource.Protocol == 'File') {
|
||||
mediaUrl = FileSystemBridge.translateFilePath(mediaUrl);
|
||||
}
|
||||
|
||||
playMethod = 'DirectPlay';
|
||||
|
||||
} else {
|
||||
|
@ -965,9 +975,6 @@
|
|||
|
||||
mediaUrl = mediaSource.Path;
|
||||
|
||||
if (mediaSource.Protocol == 'File') {
|
||||
mediaUrl = FileSystemBridge.translateFilePath(mediaUrl);
|
||||
}
|
||||
playMethod = 'DirectPlay';
|
||||
|
||||
} else {
|
||||
|
@ -1063,7 +1070,7 @@
|
|||
}
|
||||
};
|
||||
|
||||
function playOnDeviceProfileCreated(deviceProfile, item, startPosition, callback) {
|
||||
self.tryStartPlayback = function (deviceProfile, item, startPosition, callback) {
|
||||
|
||||
if (item.MediaType === "Video") {
|
||||
|
||||
|
@ -1074,28 +1081,39 @@
|
|||
|
||||
if (validatePlaybackInfoResult(playbackInfoResult)) {
|
||||
|
||||
var mediaSource = getOptimalMediaSource(item.MediaType, playbackInfoResult.MediaSources);
|
||||
|
||||
getOptimalMediaSource(item.MediaType, playbackInfoResult.MediaSources).done(function (mediaSource) {
|
||||
if (mediaSource) {
|
||||
|
||||
if (mediaSource.RequiresOpening) {
|
||||
|
||||
MediaController.getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) {
|
||||
|
||||
openLiveStreamResult.MediaSource.enableDirectPlay = MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource);
|
||||
MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource).done(function (result) {
|
||||
|
||||
openLiveStreamResult.MediaSource.enableDirectPlay = result;
|
||||
callback(openLiveStreamResult.MediaSource);
|
||||
});
|
||||
|
||||
playInternalPostMediaSourceSelection(item, openLiveStreamResult.MediaSource, startPosition, callback);
|
||||
});
|
||||
|
||||
} else {
|
||||
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback);
|
||||
callback(mediaSource);
|
||||
}
|
||||
} else {
|
||||
Dashboard.hideModalLoadingMsg();
|
||||
MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function playOnDeviceProfileCreated(deviceProfile, item, startPosition, callback) {
|
||||
|
||||
self.tryStartPlayback(deviceProfile, item, startPosition, function (mediaSource) {
|
||||
|
||||
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback);
|
||||
});
|
||||
}
|
||||
|
||||
function playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback) {
|
||||
|
|
|
@ -1027,7 +1027,7 @@ var Dashboard = {
|
|||
name: Globalize.translate('TabSync'),
|
||||
href: "syncactivity.html",
|
||||
selected: page.classList.contains('syncConfigurationPage') || (isServicesPage && context == 'sync'),
|
||||
icon: 'refresh'
|
||||
icon: 'sync'
|
||||
}, {
|
||||
divider: true,
|
||||
name: Globalize.translate('TabExtras')
|
||||
|
@ -1965,8 +1965,6 @@ var AppInfo = {};
|
|||
return false;
|
||||
});
|
||||
|
||||
require(['filesystem']);
|
||||
|
||||
if (Dashboard.isRunningInCordova()) {
|
||||
require(['cordova/connectsdk', 'scripts/registrationservices', 'cordova/back']);
|
||||
|
||||
|
@ -2027,16 +2025,6 @@ var AppInfo = {};
|
|||
define("localassetmanager", ["apiclient/localassetmanager"]);
|
||||
}
|
||||
|
||||
if (Dashboard.isRunningInCordova() && $.browser.android) {
|
||||
define("filesystem", ["cordova/android/filesystem"]);
|
||||
}
|
||||
else if (Dashboard.isRunningInCordova()) {
|
||||
define("filesystem", ["cordova/filesystem"]);
|
||||
}
|
||||
else {
|
||||
define("filesystem", ["thirdparty/filesystem"]);
|
||||
}
|
||||
|
||||
if (Dashboard.isRunningInCordova() && $.browser.android) {
|
||||
define("nativedirectorychooser", ["cordova/android/nativedirectorychooser"]);
|
||||
}
|
||||
|
|
|
@ -282,7 +282,7 @@
|
|||
if (hasLocalSync()) {
|
||||
var targetId = ApiClient.deviceId();
|
||||
data = data.filter(function (j) {
|
||||
return TargetId = targetId;
|
||||
return j.TargetId == targetId;
|
||||
});
|
||||
}
|
||||
loadData(page, data);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
}
|
||||
|
||||
.viewMenuBar.semiTransparent {
|
||||
background-color: rgba(27, 27, 27, .70);
|
||||
background-color: rgba(27, 27, 27, .65);
|
||||
}
|
||||
|
||||
.background-theme-b {
|
||||
|
|
13
dashboard-ui/thirdparty/filesystem.js
vendored
13
dashboard-ui/thirdparty/filesystem.js
vendored
|
@ -1,13 +0,0 @@
|
|||
(function () {
|
||||
|
||||
window.FileSystemBridge = {
|
||||
|
||||
fileExists: function (path) {
|
||||
return false;
|
||||
},
|
||||
|
||||
translateFilePath: function (path) {
|
||||
return 'file://' + path;
|
||||
}
|
||||
};
|
||||
})();
|
Loading…
Add table
Add a link
Reference in a new issue