From 7dd0efdcc2ba684fd802162102fd151e3ba61153 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 30 Mar 2014 12:49:40 -0400 Subject: [PATCH] restored live tv playback in the web client --- ApiClient.js | 2 +- dashboard-ui/css/chromecast.css | 8 +- dashboard-ui/css/librarybrowser.css | 18 +++ dashboard-ui/dlnaprofile.html | 50 ++++++++- dashboard-ui/scripts/addpluginpage.js | 12 +- dashboard-ui/scripts/dlnaprofile.js | 142 +++++++++++++++++------- dashboard-ui/scripts/livetvprogram.js | 1 + dashboard-ui/scripts/mediacontroller.js | 15 ++- dashboard-ui/scripts/notifications.js | 8 +- dashboard-ui/scripts/site.js | 2 +- packages.config | 2 +- 11 files changed, 197 insertions(+), 63 deletions(-) diff --git a/ApiClient.js b/ApiClient.js index ea1905bad5..f268c44ec8 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -4058,7 +4058,7 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout, wi options.ForceTitle = true; } - var url = self.getUrl("Packages/" + packageId + "Reviews", options); + var url = self.getUrl("Packages/" + packageId + "/Reviews", options); return self.ajax({ type: "GET", diff --git a/dashboard-ui/css/chromecast.css b/dashboard-ui/css/chromecast.css index 584a6a4d81..ef7fd68bfb 100644 --- a/dashboard-ui/css/chromecast.css +++ b/dashboard-ui/css/chromecast.css @@ -7,12 +7,18 @@ background-size: 100%; vertical-align: middle; margin: 0 .6em; + cursor: pointer; + border: 0 !important; } + .btnCast:hover { + opacity: .5; + } + .btnDefaultCast { background-image: url(images/chromecast/ic_media_route_off_holo_dark.png); } .btnActiveCast { background-image: url(images/chromecast/ic_media_route_on_holo_dark.png); -} \ No newline at end of file +} diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index cef8cb3881..5d12dd51a2 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -1199,3 +1199,21 @@ a.itemTag:hover { width: 32.95%; } } + +.playerSelectionPanel { + width: 250px; +} + +.ui-panel-dismiss-open.ui-panel-dismiss-position-right[data-panelid=playerSelectionPanel] { + right: 250px; +} + +@media all and (min-width: 600px) { + .playerSelectionPanel { + width: 300px; + } + + .ui-panel-dismiss-open.ui-panel-dismiss-position-right[data-panelid=playerSelectionPanel] { + right: 300px; + } +} \ No newline at end of file diff --git a/dashboard-ui/dlnaprofile.html b/dashboard-ui/dlnaprofile.html index 274977b65e..218e8df8ef 100644 --- a/dashboard-ui/dlnaprofile.html +++ b/dashboard-ui/dlnaprofile.html @@ -127,6 +127,8 @@

Add transcoding profiles to indicate which formats should be used when transcoding is required.

+ +
@@ -176,7 +178,7 @@
- +
Separated by comma. This can be left empty to apply to all containers
@@ -204,10 +206,56 @@ + + diff --git a/dashboard-ui/scripts/addpluginpage.js b/dashboard-ui/scripts/addpluginpage.js index a5163590db..235f105d42 100644 --- a/dashboard-ui/scripts/addpluginpage.js +++ b/dashboard-ui/scripts/addpluginpage.js @@ -29,21 +29,15 @@ var selectmenu = $('#selectVersion', page).html(html); - var packageVersion; - if (!installedPlugin) { $('#pCurrentVersion', page).hide().html(""); } - // If we don't have a package version to select, pick the first release build - if (!packageVersion) { + var packageVersion = packageInfo.versions.filter(function (current) { - packageVersion = packageInfo.versions.filter(function (current) { - - return current.classification == "Release"; - })[0]; - } + return current.classification == "Release"; + })[0]; // If we still don't have a package version to select, pick the first Beta build if (!packageVersion) { diff --git a/dashboard-ui/scripts/dlnaprofile.js b/dashboard-ui/scripts/dlnaprofile.js index 2704172efd..c724b151a9 100644 --- a/dashboard-ui/scripts/dlnaprofile.js +++ b/dashboard-ui/scripts/dlnaprofile.js @@ -1,4 +1,4 @@ -(function ($, document, window) { +(function($, document, window) { var currentProfile; @@ -9,7 +9,7 @@ Dashboard.showLoadingMsg(); - getProfile().done(function (result) { + getProfile().done(function(result) { currentProfile = result; @@ -38,7 +38,7 @@ $('#txtName', page).val(profile.Name); - $('.chkMediaType', page).each(function () { + $('.chkMediaType', page).each(function() { this.checked = (profile.SupportedMediaTypes || '').split(',').indexOf(this.getAttribute('data-value')) != -1; }).checkboxradio('refresh'); @@ -134,9 +134,7 @@ if (profile.Type == 'Video') { html += '

Video Codec: ' + (profile.VideoCodec || 'All') + '

'; html += '

Audio Codec: ' + (profile.AudioCodec || 'All') + '

'; - } - - else if (profile.Type == 'Audio') { + } else if (profile.Type == 'Audio') { html += '

Codec: ' + (profile.AudioCodec || 'All') + '

'; } @@ -151,13 +149,13 @@ var elem = $('.directPlayProfiles', page).html(html).trigger('create'); - $('.btnDeleteProfile', elem).on('click', function () { + $('.btnDeleteProfile', elem).on('click', function() { var index = this.getAttribute('data-profileindex'); deleteDirectPlayProfile(page, index); }); - $('.lnkEditSubProfile', elem).on('click', function () { + $('.lnkEditSubProfile', elem).on('click', function() { var index = parseInt(this.getAttribute('data-profileindex')); @@ -192,7 +190,7 @@ } html += '
  • '; - html += ''; + html += ''; html += '

    Protocol: ' + (profile.Protocol || 'Http') + '

    '; html += '

    Container: ' + (profile.Container || 'All') + '

    '; @@ -200,9 +198,7 @@ if (profile.Type == 'Video') { html += '

    Video Codec: ' + (profile.VideoCodec || 'All') + '

    '; html += '

    Audio Codec: ' + (profile.AudioCodec || 'All') + '

    '; - } - - else if (profile.Type == 'Audio') { + } else if (profile.Type == 'Audio') { html += '

    Codec: ' + (profile.AudioCodec || 'All') + '

    '; } @@ -217,11 +213,32 @@ var elem = $('.transcodingProfiles', page).html(html).trigger('create'); - $('.btnDeleteProfile', elem).on('click', function () { + $('.btnDeleteProfile', elem).on('click', function() { var index = this.getAttribute('data-profileindex'); deleteTranscodingProfile(page, index); }); + + $('.lnkEditSubProfile', elem).on('click', function () { + + var index = parseInt(this.getAttribute('data-profileindex')); + + editTranscodingProfile(page, currentProfile.TranscodingProfiles[index]); + }); + } + + function editTranscodingProfile(page, transcodingProfile) { + + isSubProfileNew = transcodingProfile == null; + transcodingProfile = transcodingProfile || {}; + currentSubProfile = transcodingProfile; + + var popup = $('#transcodingProfilePopup', page).popup('open'); + + $('#selectTranscodingProfileType', popup).val(transcodingProfile.Type || 'Video').selectmenu('refresh').trigger('change'); + $('#txtTranscodingContainer', popup).val(transcodingProfile.Container || ''); + $('#txtTranscodingAudioCodec', popup).val(transcodingProfile.AudioCodec || ''); + $('#txtTranscodingVideoCodec', popup).val(transcodingProfile.VideoCodec || ''); } function deleteTranscodingProfile(page, index) { @@ -232,6 +249,25 @@ } + function saveTranscodingProfile(page) { + + currentSubProfile.Type = $('#selectTranscodingProfileType', page).val(); + currentSubProfile.Container = $('#txtTranscodingContainer', page).val(); + currentSubProfile.AudioCodec = $('#txtTranscodingAudioCodec', page).val(); + currentSubProfile.VideoCodec = $('#txtTranscodingVideoCodec', page).val(); + + if (isSubProfileNew) { + + currentProfile.TranscodingProfiles.push(currentSubProfile); + } + + renderSubProfiles(page, currentProfile); + + currentSubProfile = null; + + $('#transcodingProfilePopup', page).popup('close'); + } + function renderContainerProfiles(page, profiles) { var html = ''; @@ -251,14 +287,14 @@ } html += '
  • '; - html += ''; + html += ''; html += '

    Container: ' + (profile.Container || 'All') + '

    '; if (profile.Conditions && profile.Conditions.length) { html += '

    Conditions: '; - html += profile.Conditions.map(function (c) { + html += profile.Conditions.map(function(c) { return c.Property; }).join(', '); html += '

    '; @@ -275,7 +311,7 @@ var elem = $('.containerProfiles', page).html(html).trigger('create'); - $('.btnDeleteProfile', elem).on('click', function () { + $('.btnDeleteProfile', elem).on('click', function() { var index = this.getAttribute('data-profileindex'); deleteContainerProfile(page, index); @@ -311,14 +347,14 @@ } html += '
  • '; - html += ''; + html += ''; html += '

    Codec: ' + (profile.Codec || 'All') + '

    '; if (profile.Conditions && profile.Conditions.length) { html += '

    Conditions: '; - html += profile.Conditions.map(function (c) { + html += profile.Conditions.map(function(c) { return c.Property; }).join(', '); html += '

    '; @@ -335,7 +371,7 @@ var elem = $('.codecProfiles', page).html(html).trigger('create'); - $('.btnDeleteProfile', elem).on('click', function () { + $('.btnDeleteProfile', elem).on('click', function() { var index = this.getAttribute('data-profileindex'); deleteCodecProfile(page, index); @@ -369,23 +405,21 @@ } html += '
  • '; - html += ''; + html += ''; html += '

    Container: ' + (profile.Container || 'All') + '

    '; if (profile.Type == 'Video') { html += '

    Video Codec: ' + (profile.VideoCodec || 'All') + '

    '; html += '

    Audio Codec: ' + (profile.AudioCodec || 'All') + '

    '; - } - - else if (profile.Type == 'Audio') { + } else if (profile.Type == 'Audio') { html += '

    Codec: ' + (profile.AudioCodec || 'All') + '

    '; } if (profile.Conditions && profile.Conditions.length) { html += '

    Conditions: '; - html += profile.Conditions.map(function (c) { + html += profile.Conditions.map(function(c) { return c.Property; }).join(', '); html += '

    '; @@ -402,7 +436,7 @@ var elem = $('.mediaProfiles', page).html(html).trigger('create'); - $('.btnDeleteProfile', elem).on('click', function () { + $('.btnDeleteProfile', elem).on('click', function() { var index = this.getAttribute('data-profileindex'); deleteMediaProfile(page, index); @@ -430,8 +464,7 @@ url: ApiClient.getUrl("Dlna/Profiles/" + id), data: JSON.stringify(profile), contentType: "application/json" - - }).done(function () { + }).done(function() { Dashboard.alert('Settings saved.'); }); @@ -443,8 +476,7 @@ url: ApiClient.getUrl("Dlna/Profiles"), data: JSON.stringify(profile), contentType: "application/json" - - }).done(function () { + }).done(function() { Dashboard.navigate('dlnaprofiles.html'); @@ -460,7 +492,7 @@ profile.Name = $('#txtName', page).val(); profile.EnableAlbumArtInDidl = $('#chkEnableAlbumArtInDidl', page).checked(); - profile.SupportedMediaTypes = $('.chkMediaType:checked', page).get().map(function (c) { + profile.SupportedMediaTypes = $('.chkMediaType:checked', page).get().map(function(c) { return c.getAttribute('data-value'); }).join(','); @@ -477,18 +509,18 @@ profile.Identification.DeviceDescription = $('#txtIdDeviceDescription', page).val(); } - $(document).on('pageinit', "#dlnaProfilePage", function () { + $(document).on('pageinit', "#dlnaProfilePage", function() { var page = this; - $('.radioProfileTab', page).on('change', function () { + $('.radioProfileTab', page).on('change', function() { $('.profileTab', page).hide(); $('.' + this.value, page).show(); }); - $('#selectDirectPlayProfileType', page).on('change', function () { + $('#selectDirectPlayProfileType', page).on('change', function() { if (this.value == 'Video') { $('#fldDirectPlayVideoCodec', page).show(); @@ -504,19 +536,41 @@ }); - $('.btnAddDirectPlayProfile', page).on('click', function () { + $('#selectTranscodingProfileType', page).on('change', function () { + + if (this.value == 'Video') { + $('#fldTranscodingVideoCodec', page).show(); + } else { + $('#fldTranscodingVideoCodec', page).hide(); + } + + if (this.value == 'Photo') { + $('#fldTranscodingAudioCodec', page).hide(); + } else { + $('#fldTranscodingAudioCodec', page).show(); + } + + }); + + $('.btnAddDirectPlayProfile', page).on('click', function() { editDirectPlayProfile(page); }); - }).on('pageshow', "#dlnaProfilePage", function () { + $('.btnAddTranscodingProfile', page).on('click', function () { + + editTranscodingProfile(page); + + }); + + }).on('pageshow', "#dlnaProfilePage", function() { var page = this; loadProfile(page); - }).on('pagebeforeshow', "#dlnaProfilePage", function () { + }).on('pagebeforeshow', "#dlnaProfilePage", function() { var page = this; @@ -526,8 +580,7 @@ }); window.DlnaProfilePage = { - - onSubmit: function () { + onSubmit: function() { Dashboard.showLoadingMsg(); @@ -539,7 +592,7 @@ return false; }, - onDirectPlayFormSubmit: function () { + onDirectPlayFormSubmit: function() { var form = this; var page = $(form).parents('.page'); @@ -547,6 +600,17 @@ saveDirectPlayProfile(page); return false; + }, + + onTranscodingProfileFormSubmit: function() { + + var form = this; + var page = $(form).parents('.page'); + + saveTranscodingProfile(page); + + return false; + } }; diff --git a/dashboard-ui/scripts/livetvprogram.js b/dashboard-ui/scripts/livetvprogram.js index 8a43bf9885..6c8e4f30bb 100644 --- a/dashboard-ui/scripts/livetvprogram.js +++ b/dashboard-ui/scripts/livetvprogram.js @@ -114,6 +114,7 @@ ApiClient.getLiveTvChannel(currentItem.ChannelId, Dashboard.getCurrentUserId()).done(function (channel) { var userdata = channel.UserData || {}; + LibraryBrowser.showPlayMenu(this, channel.Id, channel.Type, false, channel.MediaType, userdata.PlaybackPositionTicks); }); }); diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index fc69934b96..893bbe5b3e 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -200,8 +200,8 @@ var playerInfo = MediaController.getPlayerInfo(); var html = ''; + html += '

    Select Player:

    '; html += '
    '; - html += 'Select Player:'; for (var i = 0, length = targets.length; i < length; i++) { @@ -223,14 +223,17 @@ } html += '
    '; + + html += '

    All plays will be sent to the selected player.

    '; + return html; } - function showPlayerSelection() { + function showPlayerSelection(page) { var promise = MediaController.getTargets(); - - var html = '
    '; + + var html = '
    '; html += '
    '; @@ -238,7 +241,7 @@ $(document.body).append(html); - var elem = $('#playerFlyout').panel({}).trigger('create').panel("open").on("panelafterclose", function () { + var elem = $('#playerSelectionPanel').panel({}).trigger('create').panel("open").on("panelafterclose", function () { $(this).off("panelafterclose").remove(); }); @@ -270,7 +273,7 @@ $('.btnCast', page).on('click', function () { - showPlayerSelection(); + showPlayerSelection(page); }); }); diff --git a/dashboard-ui/scripts/notifications.js b/dashboard-ui/scripts/notifications.js index b1dce5f82e..1d4640a8f0 100644 --- a/dashboard-ui/scripts/notifications.js +++ b/dashboard-ui/scripts/notifications.js @@ -1,11 +1,10 @@ (function ($, document, Dashboard) { - var userId; var getNotificationsSummaryPromise; function getNotificationsSummary() { - getNotificationsSummaryPromise = getNotificationsSummaryPromise || ApiClient.getNotificationSummary(userId); + getNotificationsSummaryPromise = getNotificationsSummaryPromise || ApiClient.getNotificationSummary(Dashboard.getCurrentUserId()); return getNotificationsSummaryPromise; } @@ -64,6 +63,9 @@ $('.notificationsFlyout').popup("close"); + getNotificationsSummaryPromise = null; + + updateNotificationCount(); }); }); @@ -173,8 +175,6 @@ return; } - userId = user.Id; - $('
    0').insertAfter($('.btnCurrentUser', header)).on('click', showNotificationsFlyout); updateNotificationCount(); diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 00948fb807..8642adb936 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -475,7 +475,7 @@ var Dashboard = { Dashboard.getCurrentUser().done(function (user) { - var html = '
    '; + var html = '
    '; html += '

    '; diff --git a/packages.config b/packages.config index a5074d3c88..a874d5f6f9 100644 --- a/packages.config +++ b/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file