update client sync
This commit is contained in:
parent
0db16cad5a
commit
8bf9a6f51e
12 changed files with 133 additions and 206 deletions
|
@ -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) {
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
MediaPlayer.tryStartPlayback(deviceProfile, item, startPosition, function (mediaSource) {
|
||||
|
||||
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, deferred);
|
||||
});
|
||||
|
||||
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 () {
|
||||
|
||||
LocalAssetManager.fileExists(mediaSource.Path).done(function (exists) {
|
||||
Logger.log('LocalAssetManager.fileExists: path: ' + mediaSource.Path + ' result: ' + exists);
|
||||
deferred.resolveWith(null, [exists]);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
else {
|
||||
deferred.resolveWith(null, [false]);
|
||||
}
|
||||
return deferred.promise();
|
||||
};
|
||||
|
||||
self.showPlayerSelection = showPlayerSelection;
|
||||
|
|
|
@ -878,25 +878,39 @@
|
|||
|
||||
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);
|
||||
});
|
||||
|
||||
return v.enableDirectPlay;
|
||||
$.when.apply($, promises).done(function () {
|
||||
|
||||
})[0];
|
||||
for (var i = 0, length = versions.length; i < length; i++) {
|
||||
versions[i].enableDirectPlay = arguments[i] || false;
|
||||
}
|
||||
var optimalVersion = versions.filter(function (v) {
|
||||
|
||||
if (!optimalVersion) {
|
||||
optimalVersion = versions.filter(function (v) {
|
||||
|
||||
return v.SupportsDirectStream;
|
||||
return v.enableDirectPlay;
|
||||
|
||||
})[0];
|
||||
}
|
||||
|
||||
return optimalVersion || versions.filter(function (s) {
|
||||
return s.SupportsTranscoding;
|
||||
})[0];
|
||||
if (!optimalVersion) {
|
||||
optimalVersion = versions.filter(function (v) {
|
||||
|
||||
return v.SupportsDirectStream;
|
||||
|
||||
})[0];
|
||||
}
|
||||
|
||||
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) {
|
||||
if (mediaSource.RequiresOpening) {
|
||||
|
||||
if (mediaSource.RequiresOpening) {
|
||||
MediaController.getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) {
|
||||
|
||||
MediaController.getLiveStream(item.Id, playbackInfoResult.PlaySessionId, deviceProfile, startPosition, mediaSource, null, null).done(function (openLiveStreamResult) {
|
||||
MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource).done(function (result) {
|
||||
|
||||
openLiveStreamResult.MediaSource.enableDirectPlay = MediaController.supportsDirectPlay(openLiveStreamResult.MediaSource);
|
||||
openLiveStreamResult.MediaSource.enableDirectPlay = result;
|
||||
callback(openLiveStreamResult.MediaSource);
|
||||
});
|
||||
|
||||
playInternalPostMediaSourceSelection(item, openLiveStreamResult.MediaSource, startPosition, callback);
|
||||
});
|
||||
});
|
||||
|
||||
} else {
|
||||
callback(mediaSource);
|
||||
}
|
||||
} else {
|
||||
playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback);
|
||||
Dashboard.hideModalLoadingMsg();
|
||||
MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream');
|
||||
}
|
||||
} 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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue