diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index a44081021c..a9a4132ff6 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -438,7 +438,7 @@ if (!mute) { - this.session.setReceiverVolumeLevel(vol || 1, + this.session.setReceiverVolumeLevel((vol || 1), this.mediaCommandSuccessCallback.bind(this), this.errorHandler); } @@ -449,18 +449,6 @@ } }; - /** - * Toggle mute CC - */ - CastPlayer.prototype.toggleMute = function () { - if (this.audio == true) { - this.mute(); - } - else { - this.unMute(); - } - }; - /** * Mute CC */ @@ -469,15 +457,6 @@ this.setReceiverVolume(true); }; - /** - * Unmute CC - */ - CastPlayer.prototype.unMute = function () { - this.audio = true; - this.setReceiverVolume(false); - }; - - /** * media seek function in either Cast or local mode * @param {Event} e An event object from seek @@ -684,11 +663,19 @@ }; self.unMute = function () { - castPlayer.unMute(); + self.setVolume(getCurrentVolume() + 2); }; self.toggleMute = function () { - castPlayer.toggleMute(); + + var state = self.lastPlayerData || {}; + state = state.PlayState || {}; + + if (state.IsMuted) { + self.unMute(); + } else { + self.mute(); + } }; self.getTargets = function () { @@ -724,7 +711,10 @@ "Mute", "Unmute", "ToggleMute", - "SetVolume"] + "SetVolume", + "SetAudioStreamIndex", + "SetSubtitleStreamIndex", + "DisplayContent"] }; }; @@ -732,6 +722,24 @@ castPlayer.seekMedia(position); }; + self.setAudioStreamIndex = function (index) { + castPlayer.sendMessage({ + options: { + index: index + }, + command: 'SetAudioStreamIndex' + }); + }; + + self.setSubtitleStreamIndex = function (index) { + castPlayer.sendMessage({ + options: { + index: index + }, + command: 'SetSubtitleStreamIndex' + }); + }; + self.nextTrack = function () { castPlayer.sendMessage({ options: {}, diff --git a/dashboard-ui/scripts/itembynamedetailpage.js b/dashboard-ui/scripts/itembynamedetailpage.js index 0e2766d50f..4965ceea49 100644 --- a/dashboard-ui/scripts/itembynamedetailpage.js +++ b/dashboard-ui/scripts/itembynamedetailpage.js @@ -2,6 +2,7 @@ var currentItem; var shape; + var currentItemsQuery; function getPromise() { @@ -404,6 +405,8 @@ addCurrentItemToQuery(query); + currentItemsQuery = query; + ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { var html = ''; @@ -422,7 +425,8 @@ html = LibraryBrowser.getListViewHtml({ items: result.Items, - smallIcon: true + smallIcon: true, + playFromHere: true }); } @@ -462,7 +466,8 @@ html = LibraryBrowser.getListViewHtml({ items: result.Items, - smallIcon: true + smallIcon: true, + playFromHere: true }); } @@ -509,6 +514,16 @@ LibraryBrowser.showPlayMenu(this, currentItem.Id, currentItem.Type, false, "Audio", userdata.PlaybackPositionTicks); }); + $('.itemsContainer', page).on('playallfromhere', function (e, index) { + + LibraryBrowser.playAllFromHere(currentItemsQuery, index); + + }).on('queueallfromhere', function (e, index) { + + LibraryBrowser.queueAllFromHere(currentItemsQuery, index); + + }); + }).on('pageshow', "#itemByNameDetailPage", function () { var page = this; diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 439dc5f672..8e0e36b266 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -92,6 +92,35 @@ return "" + d.getFullYear() + formatDigit(d.getMonth() + 1) + formatDigit(d.getDate()) + formatDigit(d.getHours()) + formatDigit(d.getMinutes()) + formatDigit(d.getSeconds()); }, + playAllFromHere: function (query, index) { + + query = $.extend({}, query); + query.StartIndex = index; + query.Limit = 100; + query.Fields = "MediaSources,Chapters"; + + ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { + + MediaController.play({ + items: result.Items + }); + }); + }, + + queueAllFromHere: function (query, index) { + query = $.extend({}, query); + query.StartIndex = index; + query.Limit = 100; + query.Fields = "MediaSources,Chapters"; + + ApiClient.getItems(Dashboard.getCurrentUserId(), query).done(function (result) { + + MediaController.queue({ + items: result.Items + }); + }); + }, + getItemCountsHtml: function (options, item) { var counts = []; @@ -573,7 +602,7 @@ } var href = LibraryBrowser.getHref(item, options.context); - html += '
  • '; + html += '
  • '; var imgUrl; @@ -701,13 +730,13 @@ html += '
  • '; + index++; return html; }).join(''); outerHtml += ''; - index++; return outerHtml; }, @@ -773,6 +802,11 @@ } } + if (options.playFromHere) { + itemCommands.push('playfromhere'); + itemCommands.push('queuefromhere'); + } + return itemCommands; }, diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index 1818ebd151..b2a18c2b66 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -133,6 +133,12 @@ return html; } + function closeContextMenu() { + + // Used by the tab menu, not the slide up + $('.tapHoldMenu').popup('close'); + } + function onTrailerButtonClick() { var id = this.getAttribute('data-itemid'); @@ -141,8 +147,7 @@ MediaController.play({ items: trailers }); }); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); return false; } @@ -151,8 +156,7 @@ var card = $(this).parents('.card')[0]; - // Used by the tab menu - $('.tapHoldMenu').popup('close'); + closeContextMenu(); showContextMenu(card, { showPlayOptions: false @@ -165,36 +169,20 @@ var id = this.getAttribute('data-itemid'); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); PlaylistManager.showPanel([id]); return false; } - function onRemoveFromPlaylistButtonClick() { - - var playlistItemId = this.getAttribute('data-playlistitemid'); - - var page = $(this).parents('.page'); - - $('.itemsContainer', page).trigger('removefromplaylist', [playlistItemId]); - - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); - - return false; - } - function onShuffleButtonClick() { var id = this.getAttribute('data-itemid'); MediaController.shuffle(id); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); return false; } @@ -205,8 +193,7 @@ MediaController.instantMix(id); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); return false; } @@ -217,8 +204,7 @@ MediaController.queue(id); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); return false; } @@ -229,8 +215,52 @@ MediaController.play(id); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); + + return false; + } + + function onPlayAllFromHereButtonClick() { + + var index = this.getAttribute('data-index'); + + var page = $(this).parents('.page'); + + var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer'); + + closeContextMenu(); + + itemsContainer.trigger('playallfromhere', [index]); + + return false; + } + + function onQueueAllFromHereButtonClick() { + + var index = this.getAttribute('data-index'); + + var page = $(this).parents('.page'); + + var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer'); + + closeContextMenu(); + + itemsContainer.trigger('queueallfromhere', [index]); + + return false; + } + + function onRemoveFromPlaylistButtonClick() { + + var playlistItemId = this.getAttribute('data-playlistitemid'); + + var page = $(this).parents('.page'); + + var itemsContainer = $('.hasContextMenu', page).parents('.itemsContainer'); + + itemsContainer.trigger('removefromplaylist', [playlistItemId]); + + closeContextMenu(); return false; } @@ -244,8 +274,7 @@ startPositionTicks: parseInt(this.getAttribute('data-ticks')) }); - // Used by the tab menu, not the slide up - $('.tapHoldMenu').popup('close'); + closeContextMenu(); return false; } @@ -260,7 +289,7 @@ function showContextMenu(card, options) { - $('.tapHoldMenu').popup("close").remove(); + closeContextMenu(); var displayContextItem = card; @@ -277,6 +306,7 @@ var playAccess = card.getAttribute('data-playaccess'); var locationType = card.getAttribute('data-locationtype'); var isPlaceHolder = card.getAttribute('data-placeholder') == 'true'; + var index = card.getAttribute('data-index'); $(card).addClass('hasContextMenu'); @@ -297,8 +327,13 @@ } if (options.showPlayOptions !== false) { + if (MediaController.canPlayByAttributes(itemType, mediaType, playAccess, locationType, isPlaceHolder)) { html += '
  • ' + Globalize.translate('ButtonPlay') + '
  • '; + + if (commands.indexOf('playfromhere') != -1) { + html += '
  • ' + Globalize.translate('ButtonPlayAllFromHere') + '
  • '; + } } if (playbackPositionTicks && mediaType != "Audio") { @@ -312,6 +347,10 @@ if (MediaController.canQueueMediaType(mediaType, itemType)) { html += '
  • ' + Globalize.translate('ButtonQueue') + '
  • '; + + if (commands.indexOf('queuefromhere') != -1) { + html += '
  • ' + Globalize.translate('ButtonQueueAllFromHere') + '
  • '; + } } if (commands.indexOf('instantmix') != -1) { @@ -350,6 +389,8 @@ $('.btnPlayTrailer', elem).on('click', onTrailerButtonClick); $('.btnAddToPlaylist', elem).on('click', onAddToPlaylistButtonClick); $('.btnRemoveFromPlaylist', elem).on('click', onRemoveFromPlaylistButtonClick); + $('.btnPlayAllFromHere', elem).on('click', onPlayAllFromHereButtonClick); + $('.btnQueueAllFromHere', elem).on('click', onQueueAllFromHereButtonClick); }); } diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index 3e85c31f91..f3aa00d0aa 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -9,10 +9,10 @@ MediaController.getCurrentPlayer().displayContent({ - itemName: item.Name, - itemId: item.Id, - itemType: item.Type, - context: info.context + ItemName: item.Name, + ItemId: item.Id, + ItemType: item.Type, + Context: info.context }); } diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index ad1d3d5088..dedc5edaee 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -435,6 +435,7 @@ self.playlist = items; currentPlaylistIndex = 0; + return; } ApiClient.getJSON(ApiClient.getUrl('Users/' + user.Id + '/Items/' + firstItem.Id + '/Intros')).done(function (intros) { diff --git a/dashboard-ui/scripts/playlistedit.js b/dashboard-ui/scripts/playlistedit.js index bdf226823b..3063bcf2e0 100644 --- a/dashboard-ui/scripts/playlistedit.js +++ b/dashboard-ui/scripts/playlistedit.js @@ -75,7 +75,8 @@ showIndex: false, title: item.Name, showRemoveFromPlaylist: true, - smallIcon: true + smallIcon: true, + playFromHere: true }); } @@ -181,6 +182,24 @@ removeFromPlaylist(page, [playlistItemId]); + }).on('playallfromhere', function (e, index) { + + LibraryBrowser.playAllFromHere({ + + Recursive: true, + ParentId: query.ParentId + + }, index); + + }).on('queueallfromhere', function (e, index) { + + LibraryBrowser.queueAllFromHere({ + + Recursive: true, + ParentId: query.ParentId + + }, index); + }); }).on('pagebeforeshow', "#playlistEditorPage", function () { diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 57d35e61e7..9e08273809 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1274,14 +1274,13 @@ $(document).on('pagebeforeshow', ".page", function () { var page = $(this); - var userId = Dashboard.getCurrentUserId(); - - if (userId) { + if (Dashboard.getAccessToken() && Dashboard.getCurrentUserId()) { Dashboard.getCurrentUser().done(function (user) { if (!user.Configuration.IsAdministrator && page.hasClass('type-interior') && !page.hasClass('publicUserPage')) { window.location.replace("index.html"); + return; } Dashboard.ensureToolsMenu(page, user);