diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index 85bebcf1f..a44081021 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -211,6 +211,11 @@ $(this).trigger('connect'); MediaController.setActivePlayer(PlayerName); + + this.sendMessage({ + options: {}, + command: 'Identify' + }); }; /** @@ -288,6 +293,22 @@ }); }; + var endpointInfo; + function getEndpointInfo() { + + if (endpointInfo) { + + var deferred = $.Deferred(); + deferred.resolveWith(null, [endpointInfo]); + return deferred.promise(); + } + + return ApiClient.getJSON(ApiClient.getUrl('System/Endpoint')).done(function (info) { + + endpointInfo = info; + }); + } + CastPlayer.prototype.sendMessage = function (message) { var player = this; @@ -299,19 +320,18 @@ serverAddress: ApiClient.serverAddress() }); - // If the user is on localhost we need a different address to send to the receiver - var address = message.serverAddress.toLowerCase(); - if (address.indexOf('localhost') != -1 || address.indexOf('127.0.0') != -1) { + getEndpointInfo().done(function (endpoint) { - ApiClient.getSystemInfo().done(function (info) { + if (endpoint.IsLocal || endpoint.IsInNetwork) { + ApiClient.getSystemInfo().done(function (info) { - message.serverAddress = info.WanAddress; + message.serverAddress = info.LocalAddress; + player.sendMessageInternal(message); + }); + } else { player.sendMessageInternal(message); - }); - - } else { - player.sendMessageInternal(message); - } + } + }); }; CastPlayer.prototype.sendMessageInternal = function (message) { @@ -375,18 +395,8 @@ return; } - switch (this.castPlayerState) { - case PLAYER_STATE.LOADED: - case PLAYER_STATE.PAUSED: - this.currentMediaSession.play(null, - this.mediaCommandSuccessCallback.bind(this, "playing started for " + this.currentMediaSession.sessionId), - this.errorHandler); - this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler); - this.castPlayerState = PLAYER_STATE.PLAYING; - break; - default: - break; - } + this.currentMediaSession.play(null, this.mediaCommandSuccessCallback.bind(this, "playing started for " + this.currentMediaSession.sessionId), this.errorHandler); + //this.currentMediaSession.addUpdateListener(this.mediaStatusUpdateHandler); }; /** @@ -398,12 +408,7 @@ return; } - if (this.castPlayerState == PLAYER_STATE.PLAYING) { - this.castPlayerState = PLAYER_STATE.PAUSED; - this.currentMediaSession.pause(null, - this.mediaCommandSuccessCallback.bind(this, "paused " + this.currentMediaSession.sessionId), - this.errorHandler); - } + this.currentMediaSession.pause(null, this.mediaCommandSuccessCallback.bind(this, "paused " + this.currentMediaSession.sessionId), this.errorHandler); }; /** @@ -719,8 +724,7 @@ "Mute", "Unmute", "ToggleMute", - "SetVolume", - "DisplayContent"] + "SetVolume"] }; }; diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index c02e55f96..439dc5f67 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -182,126 +182,6 @@ return counts.join(' • '); }, - getSongHeaderCellHtml: function (text, cssClass, enableSorting, sortField, selectedSortField, sortDirection) { - - var html = cssClass ? '
' + (item.Name || "") + ' | '; - - if (options.showAlbum) { - if (item.Album && item.ParentId) { - html += '' + item.Album + ' | '; - } else { - html += '' + (item.Album || '') + ' | '; - } - } - - if (options.showArtist) { - - if (item.Artists && item.Artists.length) { - - var artistLinksHtml = LibraryBrowser.getArtistLinksHtml(item.Artists); - - html += '' + artistLinksHtml + ' | '; - } else { - html += ''; - } - } - - if (options.showAlbumArtist) { - - if (item.AlbumArtist) { - - html += ' | ' + LibraryBrowser.getArtistLinksHtml([item.AlbumArtist]) + ' | '; - - } else { - html += ''; - } - } - - var time = Dashboard.getDisplayTime(item.RunTimeTicks || 0); - - html += ' | ' + time + ' | '; - - html += '' + (item.UserData ? item.UserData.PlayCount : 0) + ' | '; - - html += ''; - html += ''; - html += ' | '; - - html += '