From c018f44379e400d7935b61e3d592ed04f03b78ef Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 11 Jul 2013 16:25:12 -0400 Subject: [PATCH] added remote control menu --- dashboard-ui/css/images/remote.png | Bin 0 -> 1732 bytes dashboard-ui/css/librarybrowser.css | 2 +- dashboard-ui/css/remotecontrol.css | 4 + dashboard-ui/scripts/Itemdetailpage.js | 2 +- dashboard-ui/scripts/itembynamedetailpage.js | 2 +- dashboard-ui/scripts/librarybrowser.js | 2 + dashboard-ui/scripts/mediaplayer.js | 6 +- dashboard-ui/scripts/moviegenres.js | 2 +- dashboard-ui/scripts/moviepeople.js | 2 +- dashboard-ui/scripts/moviestudios.js | 2 +- dashboard-ui/scripts/musicgenres.js | 2 +- dashboard-ui/scripts/remotecontrol.js | 243 ++++++++++++++++++- 12 files changed, 254 insertions(+), 15 deletions(-) create mode 100644 dashboard-ui/css/images/remote.png diff --git a/dashboard-ui/css/images/remote.png b/dashboard-ui/css/images/remote.png new file mode 100644 index 0000000000000000000000000000000000000000..66f8a55271589d3595be94c9eae14ac57330ea85 GIT binary patch literal 1732 zcmV;#20QtQP)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D23bi&K~#8N-J36L z97hy~eU?FhL4Yj<6c|`)fk8k(Kq?uuYJq`4Kq>{eQb0g}fk8k)q=JA{3J5R=2#6|! zRC1~UgMffk3J7qds0s*hrGS7$3P`0`ie&fu%{{MfZ)bLA_V(6$_eoE)JM-q>-t3#1 zw{yLj2#$}B7m#%>e?XRzv&gw#ulGIjH`mh(9p5-QI{HZHjAj?-7lNRb&a7Gxh0%jy_PQPvHIqf%knUUIub{9*8pXE6kw?h;zLw*RB~LbV>biBv!TkeEa&W(i48I-+mOOFHS~$qp7M}2r zh3foe=KZ^f8}9V|5P8YvAG)6k=;VF(vl`s5DW1zST)*qbI&L8gE>jK2J5PBJ2`^bx zH=t1(;xCXLMOLky~XEAnr(9{F?)56B!A*}EK?%Qp*p`n`M_BDKCK=-v?8)OT4 zZqZ&yzi!oZ6WXXL?rFcd)u8(qL2m0zT$$%dJJa)~+AU~U>J+CLp|F1-PWy~EPRWC% zb!&Yg8&Cbp)BHyx*S>!(1RYsnd$YbP#MHQgzbsoZ| z-Hsm`lk*h&ApM4^XArFgQk2a=PwRi@eiKAh`48H)2UNCYb%*fI)8vy|trGOSzbNs+ zMHXoz+k@y=fMNX`l|8oG0u0Ol?6MZ*50(A9g$2kX=gUL8twoXzpu(T2@L#*lL40Tr z|DA<(DRsZmrZwumX}9BtVHa|K$QzWoxVhHyHn_(3;Ozuu#JJMbp7z}9R2cknOxiy3 z6p5bOg*t&`?s1}$9w54J32J|*NQMe)Er+X6N08(PD9E#C%^N?|ca{oMrZ|0bTp;|4 z@Fro>Mk;~!>;aXXrz2JC1MmB34(k!(B`TBy(+g=qKR;<&$iz_S3~|FBYjcpM?R7hcHmFEG z0w9S?xs<`Sz^50>sNmw=)U^ zmC5f{3XRf8DeU%$)A^%l^uUl`EU#9m-q(Zpc8}svVU@3c%T#j^zicX%SZAG)B&_lx z-F6kU1$9>01Mhno`vB0BadQ@)aEW`JXbnPo`-d;6SJRc(9uV){y%ArzPe4b*{-Wvs zh=h*xXP|RBr%$L@Q(1C_oi;%6Z8XEQ%(;Wq5mNyeO^Ofdj@y> zj_asbV;J&jJKf$IpbQ!lvn4or0O6hCg}D a%={0whwE!@GM&f(0000' + (view == 'games' ? selectedHtml : '') + 'Games'; } + html += 'Remote Control'; + html += '
'; html += Search.getSearchHtml(); diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 079dcc5a74..6b36b28f3c 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -101,7 +101,7 @@ clearProgressInterval(); - var intervalTime = ApiClient.isWebSocketOpen() ? 10000 : 30000; + var intervalTime = ApiClient.isWebSocketOpen() ? 5000 : 20000; currentProgressInterval = setInterval(function () { @@ -831,6 +831,10 @@ self.playInternal = function (item, startPosition, user) { + if (item == null) { + throw new Error("item cannot be null"); + } + if (self.isPlaying()) { self.stop(); } diff --git a/dashboard-ui/scripts/moviegenres.js b/dashboard-ui/scripts/moviegenres.js index 46c50739c8..0f352d6137 100644 --- a/dashboard-ui/scripts/moviegenres.js +++ b/dashboard-ui/scripts/moviegenres.js @@ -5,7 +5,7 @@ SortBy: "SortName", SortOrder: "Ascending", - IncludeItemTypes: "Movie", + IncludeItemTypes: "Movie,Trailer", Recursive: true, Fields: "ItemCounts,DateCreated,UserData", StartIndex: 0 diff --git a/dashboard-ui/scripts/moviepeople.js b/dashboard-ui/scripts/moviepeople.js index 618cae0790..dc54635fb6 100644 --- a/dashboard-ui/scripts/moviepeople.js +++ b/dashboard-ui/scripts/moviepeople.js @@ -5,7 +5,7 @@ SortBy: "SortName", SortOrder: "Ascending", - IncludeItemTypes: "Movie", + IncludeItemTypes: "Movie,Trailer", Recursive: true, Fields: "ItemCounts,DateCreated,UserData", PersonTypes: "", diff --git a/dashboard-ui/scripts/moviestudios.js b/dashboard-ui/scripts/moviestudios.js index 7336b4bd3f..a3516f145f 100644 --- a/dashboard-ui/scripts/moviestudios.js +++ b/dashboard-ui/scripts/moviestudios.js @@ -5,7 +5,7 @@ SortBy: "SortName", SortOrder: "Ascending", - IncludeItemTypes: "Movie", + IncludeItemTypes: "Movie,Trailer", Recursive: true, Fields: "ItemCounts,DateCreated,UserData", StartIndex: 0 diff --git a/dashboard-ui/scripts/musicgenres.js b/dashboard-ui/scripts/musicgenres.js index bb46318561..b63545aec2 100644 --- a/dashboard-ui/scripts/musicgenres.js +++ b/dashboard-ui/scripts/musicgenres.js @@ -5,7 +5,7 @@ SortBy: "SortName", SortOrder: "Ascending", - IncludeItemTypes: "Audio", + IncludeItemTypes: "Audio,MusicVideo", Recursive: true, Fields: "ItemCounts,DateCreated,UserData", StartIndex: 0 diff --git a/dashboard-ui/scripts/remotecontrol.js b/dashboard-ui/scripts/remotecontrol.js index 7895159dd3..a6b4ab7b14 100644 --- a/dashboard-ui/scripts/remotecontrol.js +++ b/dashboard-ui/scripts/remotecontrol.js @@ -27,7 +27,7 @@ } - function showMenu(options, sessionsPromise) { + function showMenuForItem(options, sessionsPromise) { var playFromRendered; var trailersRendered; @@ -204,11 +204,12 @@ var deviceId = ApiClient.deviceId(); + // don't display the current session sessions = sessions.filter(function (s) { return s.DeviceId != deviceId; }); - renderSessions(sessions, options, elem); + renderSessionsInPlayMenu(sessions, options, elem); if (ApiClient.isWebSocketOpen()) { ApiClient.sendWebSocketMessage("SessionsStart", "1500,1500"); @@ -216,7 +217,7 @@ $(ApiClient).on("websocketmessage.remotecontrol", function (e, msg) { if (msg.MessageType === "Sessions") { - refreshSessions(msg.Data, elem); + updateSessionsInPlayMenu(msg.Data, elem); } }); @@ -392,7 +393,7 @@ $('.chkSelectPlayTime:first', elem).checked(true); } - function renderSessions(sessions, options, elem) { + function renderSessionsInPlayMenu(sessions, options, elem) { if (!sessions.length) { elem.html('

There are currently no available media browser sessions to control.

'); @@ -536,7 +537,7 @@ return html; } - function refreshSessions(sessions, elem) { + function updateSessionsInPlayMenu(sessions, elem) { for (var i = 0, length = sessions.length; i < length; i++) { @@ -612,12 +613,240 @@ $('.chkSelectItem:first', elem).checked(true); } + function showMenu(sessions) { + + var html = '
'; + + html += '
'; + html += '
Remote Control
'; + html += '
'; + + html += '
'; + + html += '
'; + + // Add controls here + html += '
'; + html += '
'; + + html += '
'; + + html += '
'; + + html += ''; + + html += ''; + + html += '
'; + + html += '

'; + + html += ''; + + html += '

'; + + html += '
'; + + html += '
'; + + $(document.body).append(html); + + var popup = $('#remoteControlFlyout').popup({ history: false, tolerance: 0, corners: false }).trigger('create').popup("open").on("popupafterclose", function () { + + if (ApiClient.isWebSocketOpen()) { + ApiClient.sendWebSocketMessage("SessionsStop"); + } + + $(ApiClient).off("websocketmessage.remotecontrol"); + + $(this).off("popupafterclose").remove(); + }); + + renderSessionsInControlMenu(popup, sessions); + updateSessionInfo(popup, sessions); + + if (ApiClient.isWebSocketOpen()) { + ApiClient.sendWebSocketMessage("SessionsStart", "1500,1500"); + + $(ApiClient).on("websocketmessage.remotecontrol", function (e, msg) { + + if (msg.MessageType === "Sessions") { + + // Update existing data + updateSessionInfo(popup, msg.Data); + } + }); + + } + } + + function getPlaybackHtml() { + + var html = ''; + + html += '

'; + + html += '

'; + + html += '
'; + + html += '
'; + html += ''; + html += ' / '; + html += ''; + html += '
'; + + html += ''; + html += '
'; + + html += '
'; + html += ''; + html += ''; + html += ''; + html += ''; + html += ''; + html += '
'; + + + return html; + } + + function updateSessionInfo(popup, sessions) { + + var id = $('#selectSession', popup).val(); + + // don't display the current session + var session = sessions.filter(function (s) { + return s.Id == id; + })[0]; + + if (session && session.NowPlayingItem) { + + $('.nothingPlaying', popup).hide(); + + var elem = $('.nowPlaying', popup).show(); + + updateNowPlaying(elem, session); + + } else { + + $('.nothingPlaying', popup).show(); + $('.nowPlaying', popup).hide(); + } + } + + function updateNowPlaying(elem, session) { + + var item = session.NowPlayingItem; + + $('.nowPlayingTitle', elem).html(item.Name); + + var imageContainer = $('.nowPlayingImage', elem); + + if (item.PrimaryImageTag) { + imageContainer.show(); + + var img = $('img', imageContainer)[0]; + + var imgUrl = ApiClient.getImageUrl(item.Id, { + maxheight: 200, + type: 'Primary', + tag: item.PrimaryImageTag + }); + + if (!img || img.src.toLowerCase().indexOf(imgUrl.toLowerCase()) == -1) { + imageContainer.html(''); + } + + } else { + imageContainer.hide(); + } + + var time = session.NowPlayingPositionTicks || 0; + var duration = item.RunTimeTicks || 0; + + var percent = duration ? 100 * time / duration : 0; + + $('#positionSlider', elem).val(percent).slider('refresh'); + + $('.nowPlayingTime', elem).html(Dashboard.getDisplayTime(time)); + $('.duration', elem).html(Dashboard.getDisplayTime(duration)); + + if (session.IsPaused) { + $('.btnPauseParent', elem).hide(); + $('.btnPlayParent', elem).show(); + } else { + $('.btnPauseParent', elem).show(); + $('.btnPlayParent', elem).hide(); + } + } + + function renderSessionsInControlMenu(popup, sessions) { + + var deviceId = ApiClient.deviceId(); + + // don't display the current session + sessions = sessions.filter(function (s) { + return s.DeviceId != deviceId && s.SupportsRemoteControl; + }); + + var elem = $('#selectSession', popup); + + var currentValue = elem.val(); + + if (currentValue) { + + // Make sure the session is still active + var currentSession = sessions.filter(function (s) { + return s.Id == currentValue; + })[0]; + + if (!currentSession) { + currentValue = null; + } + } + + if (!currentValue && sessions.length) { + currentValue = sessions[0].Id; + } + + var html = ''; + + for (var i = 0, length = sessions.length; i < length; i++) { + + var session = sessions[i]; + + var text = session.Client + ' - ' + session.DeviceName; + + if (session.UserName) { + text += ' - ' + session.UserName; + } + + html += ''; + } + + elem.html(html).val(currentValue).selectmenu('refresh'); + + } + function remoteControl() { var self = this; - self.showMenu = function (options) { - showMenu(options, ApiClient.getSessions({ SupportsRemoteControl: true })); + self.showMenuForItem = function (options) { + showMenuForItem(options, ApiClient.getSessions({ SupportsRemoteControl: true })); + }; + + self.showMenu = function () { + ApiClient.getSessions({ SupportsRemoteControl: true }).done(function (sessions) { + + showMenu(sessions); + + }); }; }