From 6e6bf85030ffae9ce71a0f69854414eade4aade8 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 3 Jun 2015 01:30:14 -0400 Subject: [PATCH] add js local asset manager --- dashboard-ui/css/librarymenu.css | 2 +- dashboard-ui/scripts/mediacontroller.js | 46 +++++++++++++++++++ dashboard-ui/scripts/site.js | 19 ++++++++ dashboard-ui/scripts/syncactivity.js | 6 ++- .../thirdparty/apiclient/localassetmanager.js | 11 +++++ .../cordova/android/localassetmanager.js | 11 +++++ 6 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 dashboard-ui/thirdparty/apiclient/localassetmanager.js create mode 100644 dashboard-ui/thirdparty/cordova/android/localassetmanager.js diff --git a/dashboard-ui/css/librarymenu.css b/dashboard-ui/css/librarymenu.css index 9dc9e25785..895a2923e4 100644 --- a/dashboard-ui/css/librarymenu.css +++ b/dashboard-ui/css/librarymenu.css @@ -282,7 +282,7 @@ } } -@media all and (max-width: 1440px) { +@media all and (max-width: 1280px) { /* They can use the left menu */ .dashboardEntryHeaderButton { diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index 4317cd864d..8e543e0521 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -488,8 +488,54 @@ }; + function getPlaybackInfoFromLocalMediaSource(itemId, deviceProfile, startPosition, mediaSource) { + + mediaSource.SupportsDirectPlay = true; + + return { + + MediaSources: [mediaSource], + + // Just dummy this up + PlaySessionId: new Date().getTime().toString() + }; + + } + self.getPlaybackInfo = function (itemId, deviceProfile, startPosition, mediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId) { + var deferred = DeferredBuilder.Deferred(); + + Dashboard.loadLocalAssetManager().done(function () { + + var serverInfo = ApiClient.serverInfo().Id; + + if (serverInfo.Id) { + var localMediaSource = window.LocalAssetManager.getLocalMediaSource(serverInfo.Id, itemId); + + // Use the local media source if a specific one wasn't requested, or the smae one was requested + if (localMediaSource && (!mediaSource || mediaSource.Id == localMediaSource.Id)) { + + var playbackInfo = getPlaybackInfoFromLocalMediaSource(itemId, deviceProfile, startPosition, localMediaSource); + + deferred.resolveWith(null, [playbackInfo]); + return; + } + } + + self.getPlaybackInfoInternal(itemId, deviceProfile, startPosition, mediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId).done(function (result) { + deferred.resolveWith(null, [result]); + }).fail(function () { + deferred.reject(); + }); + + }); + + return deferred.promise(); + } + + self.getPlaybackInfoInternal = function (itemId, deviceProfile, startPosition, mediaSource, audioStreamIndex, subtitleStreamIndex, liveStreamId) { + var postData = { DeviceProfile: deviceProfile }; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 2e403ba510..434988d984 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1448,6 +1448,25 @@ var Dashboard = { return deferred.promise(); }, + loadLocalAssetManager: function () { + + var deferred = DeferredBuilder.Deferred(); + + var file = 'thirdparty/apiclient/localassetmanager'; + + if (AppInfo.isNativeApp && $.browser.android) { + file = 'thirdparty/cordova/android/localassetmanager'; + } + + require([ + file + ], function () { + + deferred.resolve(); + }); + return deferred.promise(); + }, + ready: function (fn) { if (Dashboard.initPromiseDone) { diff --git a/dashboard-ui/scripts/syncactivity.js b/dashboard-ui/scripts/syncactivity.js index 3826f0de8a..6e64c1db16 100644 --- a/dashboard-ui/scripts/syncactivity.js +++ b/dashboard-ui/scripts/syncactivity.js @@ -123,8 +123,10 @@ textLines.push(' '); } - html += '
'; - html += ''; + html += '
'; + html += ''; html += "
"; for (var i = 0, length = textLines.length; i < length; i++) { diff --git a/dashboard-ui/thirdparty/apiclient/localassetmanager.js b/dashboard-ui/thirdparty/apiclient/localassetmanager.js new file mode 100644 index 0000000000..749e5286f3 --- /dev/null +++ b/dashboard-ui/thirdparty/apiclient/localassetmanager.js @@ -0,0 +1,11 @@ +(function () { + + function getLocalMediaSource(serverId, itemId) { + return null; + } + + window.LocalAssetManager = { + getLocalMediaSource: getLocalMediaSource + }; + +})(); \ No newline at end of file diff --git a/dashboard-ui/thirdparty/cordova/android/localassetmanager.js b/dashboard-ui/thirdparty/cordova/android/localassetmanager.js new file mode 100644 index 0000000000..749e5286f3 --- /dev/null +++ b/dashboard-ui/thirdparty/cordova/android/localassetmanager.js @@ -0,0 +1,11 @@ +(function () { + + function getLocalMediaSource(serverId, itemId) { + return null; + } + + window.LocalAssetManager = { + getLocalMediaSource: getLocalMediaSource + }; + +})(); \ No newline at end of file