From 2e982826bb64b3f786c1a8911dbdeea5c4327618 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sun, 24 May 2015 14:33:28 -0400 Subject: [PATCH] fix audio-only hls --- dashboard-ui/css/librarybrowser.css | 9 ++- dashboard-ui/css/mediaplayer.css | 14 +++- dashboard-ui/scripts/backdrops.js | 8 +-- dashboard-ui/scripts/chromecast.js | 14 +++- dashboard-ui/scripts/indexpage.js | 2 +- dashboard-ui/scripts/librarylist.js | 8 ++- dashboard-ui/scripts/mediaplayer.js | 65 +++++++++---------- dashboard-ui/scripts/moviesrecommended.js | 2 +- dashboard-ui/scripts/musicrecommended.js | 2 +- dashboard-ui/scripts/site.js | 7 +- dashboard-ui/scripts/tvrecommended.js | 2 +- .../thirdparty/apiclient/connectionmanager.js | 13 ++-- .../thirdparty/apiclient/credentials.js | 10 +++ 13 files changed, 99 insertions(+), 57 deletions(-) diff --git a/dashboard-ui/css/librarybrowser.css b/dashboard-ui/css/librarybrowser.css index de1e1a146..3e57f2b24 100644 --- a/dashboard-ui/css/librarybrowser.css +++ b/dashboard-ui/css/librarybrowser.css @@ -1535,7 +1535,7 @@ span.itemCommunityRating:not(:empty) + .userDataIcons { } .detailsMenuContentInner { - height: 200px; + height: 220px; } .detailsMenuOverview { @@ -1573,6 +1573,13 @@ span.itemCommunityRating:not(:empty) + .userDataIcons { line-height: .5; } +@media all and (max-height:500px) { + + .detailsMenuUserData { + display: none; + } +} + @media all and (min-height:500px) { .detailsMenuContentInner { diff --git a/dashboard-ui/css/mediaplayer.css b/dashboard-ui/css/mediaplayer.css index acacd002d..a61ced8b5 100644 --- a/dashboard-ui/css/mediaplayer.css +++ b/dashboard-ui/css/mediaplayer.css @@ -39,7 +39,19 @@ vertical-align: middle; text-align: left; font-size: 15px; - max-width: 150px; + max-width: 130px; +} + +@media (min-width: 500px) { + .nowPlayingText { + max-width: 180px; + } +} + +@media (min-width: 600px) { + .nowPlayingText { + max-width: 200px; + } } @media (min-width: 800px) { diff --git a/dashboard-ui/scripts/backdrops.js b/dashboard-ui/scripts/backdrops.js index 9508973b4..f4f96c9eb 100644 --- a/dashboard-ui/scripts/backdrops.js +++ b/dashboard-ui/scripts/backdrops.js @@ -128,13 +128,11 @@ return false; } - if (!$.browser.mobile) { - return true; + if ($.browser.mobile) { + return false; } - var screenWidth = $(window).width(); - - return screenWidth >= 600; + return true; } function enabled() { diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index 07633982c..09d3e09ff 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -28,8 +28,11 @@ var PlayerName = 'Chromecast'; - var applicationID = "2D4B1DA3"; - var messageNamespace = 'urn:x-cast:com.connectsdk'; + //var applicationID = "2D4B1DA3"; + //var messageNamespace = 'urn:x-cast:com.connectsdk'; + + var applicationID = "F4EB2E8E"; + var messageNamespace = 'urn:x-cast:com.google.cast.mediabrowser.v3'; var CastPlayer = function () { @@ -184,6 +187,8 @@ this.session = null; this.deviceState = DEVICE_STATE.IDLE; this.castPlayerState = PLAYER_STATE.IDLE; + + console.log('sessionUpdateListener: setting currentMediaSession to null'); this.currentMediaSession = null; MediaController.removeActivePlayer(PlayerName); @@ -271,6 +276,8 @@ console.log(message); this.deviceState = DEVICE_STATE.IDLE; this.castPlayerState = PLAYER_STATE.IDLE; + + console.log('onStopAppSuccess: setting currentMediaSession to null'); this.currentMediaSession = null; }; @@ -405,6 +412,7 @@ CastPlayer.prototype.setReceiverVolume = function (mute, vol) { if (!this.currentMediaSession) { + console.log('this.currentMediaSession is null'); return; } @@ -425,7 +433,6 @@ * Mute CC */ CastPlayer.prototype.mute = function () { - this.audio = false; this.setReceiverVolume(true); }; @@ -613,6 +620,7 @@ options: {}, command: 'Mute' }); + //castPlayer.mute(); }; self.unMute = function () { diff --git a/dashboard-ui/scripts/indexpage.js b/dashboard-ui/scripts/indexpage.js index d243f4614..5a7493c3e 100644 --- a/dashboard-ui/scripts/indexpage.js +++ b/dashboard-ui/scripts/indexpage.js @@ -15,7 +15,7 @@ } function enableScrollX() { - return AppInfo.isTouchPreferred; + return AppInfo.isTouchPreferred && AppInfo.enableAppLayouts; } function getThumbShape() { diff --git a/dashboard-ui/scripts/librarylist.js b/dashboard-ui/scripts/librarylist.js index 8dc85960b..5d9769995 100644 --- a/dashboard-ui/scripts/librarylist.js +++ b/dashboard-ui/scripts/librarylist.js @@ -663,7 +663,7 @@ var userData = LibraryBrowser.getUserDataIconsHtml(item); if (userData) { - contentHtml += '

' + userData + '

'; + contentHtml += '

' + userData + '

'; } var ratingHtml = LibraryBrowser.getRatingHtml(item); @@ -756,7 +756,11 @@ setItemIntoOverlay(elem, 0); } - function onCardClick() { + function onCardClick(e) { + + if ($(e.target).is('.itemSelectionPanel') || $('.itemSelectionPanel', this).length) { + return false; + } var info = LibraryBrowser.getListItemInfo(this); var itemId = info.id; diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index a38ab130f..46a1a3e68 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -37,7 +37,7 @@ return targets; }; - var supportsAac = document.createElement('audio').canPlayType('audio/aac').replace(/no/, ''); + var canPlayAac = document.createElement('audio').canPlayType('audio/aac').replace(/no/, ''); self.getVideoQualityOptions = function (videoWidth) { @@ -153,7 +153,7 @@ Type: 'Audio' }); - if (supportsAac) { + if (canPlayAac) { profile.DirectPlayProfiles.push({ Container: 'aac', Type: 'Audio' @@ -173,24 +173,6 @@ profile.TranscodingProfiles = []; - if ($.browser.safari) { - profile.TranscodingProfiles.push({ - Container: 'aac', - Type: 'Audio', - AudioCodec: 'aac', - Context: 'Streaming', - Protocol: 'http' - }); - } else { - profile.TranscodingProfiles.push({ - Container: 'mp3', - Type: 'Audio', - AudioCodec: 'mp3', - Context: 'Streaming', - Protocol: 'http' - }); - } - if (self.canPlayHls()) { profile.TranscodingProfiles.push({ Container: 'ts', @@ -200,6 +182,16 @@ Context: 'Streaming', Protocol: 'hls' }); + + if (canPlayAac) { + profile.TranscodingProfiles.push({ + Container: 'aac', + Type: 'Audio', + AudioCodec: 'aac', + Context: 'Streaming', + Protocol: 'hls' + }); + } } if (canPlayWebm) { @@ -223,6 +215,24 @@ Protocol: 'http' }); + if (canPlayAac && $.browser.safari) { + profile.TranscodingProfiles.push({ + Container: 'aac', + Type: 'Audio', + AudioCodec: 'aac', + Context: 'Streaming', + Protocol: 'http' + }); + } else { + profile.TranscodingProfiles.push({ + Container: 'mp3', + Type: 'Audio', + AudioCodec: 'mp3', + Context: 'Streaming', + Protocol: 'http' + }); + } + profile.ContainerProfiles = []; var audioConditions = []; @@ -1685,21 +1695,6 @@ var currentTicks = self.getCurrentTicks(this); self.setCurrentTime(currentTicks); - - if ($.browser.safari) { - - if (self.currentDurationTicks) { - - // Seeing transcoded audio looping in safari, going past the runtime but restarting the audio - if (currentTicks > self.currentDurationTicks) { - if (currentPlaylistIndex < self.playlist.length - 1) { - self.nextTrack(); - } else { - self.stop(); - } - } - } - } } function playAudio(item, mediaSource, startPositionTicks) { diff --git a/dashboard-ui/scripts/moviesrecommended.js b/dashboard-ui/scripts/moviesrecommended.js index 53017d22d..df183f7a6 100644 --- a/dashboard-ui/scripts/moviesrecommended.js +++ b/dashboard-ui/scripts/moviesrecommended.js @@ -11,7 +11,7 @@ } function enableScrollX() { - return AppInfo.isTouchPreferred; + return AppInfo.isTouchPreferred && AppInfo.enableAppLayouts; } function getPortraitShape() { diff --git a/dashboard-ui/scripts/musicrecommended.js b/dashboard-ui/scripts/musicrecommended.js index 61d4c36d4..718e55ec8 100644 --- a/dashboard-ui/scripts/musicrecommended.js +++ b/dashboard-ui/scripts/musicrecommended.js @@ -8,7 +8,7 @@ } function enableScrollX() { - return AppInfo.isTouchPreferred; + return AppInfo.isTouchPreferred && AppInfo.enableAppLayouts; } function getSquareShape() { diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 0806a0062..fd61199af 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1554,7 +1554,10 @@ var AppInfo = {}; AppInfo.enableMovieTrailersTab = true; } - if (!isCordova) { + if (isCordova) { + AppInfo.enableAppLayouts = true; + } + else { AppInfo.enableFooterNotifications = true; AppInfo.enableSupporterMembership = true; } @@ -1573,7 +1576,7 @@ var AppInfo = {}; .on("websocketmessage.dashboard", Dashboard.onWebSocketMessageReceived) .on('requestfail.dashboard', Dashboard.onRequestFail); } - + //localStorage.clear(); function createConnectionManager(appInfo) { var credentialProvider = new MediaBrowser.CredentialProvider(); diff --git a/dashboard-ui/scripts/tvrecommended.js b/dashboard-ui/scripts/tvrecommended.js index 3fda9532e..816a8239c 100644 --- a/dashboard-ui/scripts/tvrecommended.js +++ b/dashboard-ui/scripts/tvrecommended.js @@ -106,7 +106,7 @@ } function enableScrollX() { - return AppInfo.isTouchPreferred; + return AppInfo.isTouchPreferred && AppInfo.enableAppLayouts; } function getThumbShape() { diff --git a/dashboard-ui/thirdparty/apiclient/connectionmanager.js b/dashboard-ui/thirdparty/apiclient/connectionmanager.js index 3db258a90..951646bf7 100644 --- a/dashboard-ui/thirdparty/apiclient/connectionmanager.js +++ b/dashboard-ui/thirdparty/apiclient/connectionmanager.js @@ -101,7 +101,7 @@ return credentialProvider.credentials().ConnectAccessToken; }; - self.getLastUsedApiClient = function() { + self.getLastUsedApiClient = function () { var servers = credentialProvider.credentials().servers; @@ -129,7 +129,7 @@ })[0]; if (existingServer) { - + existingServer.DateLastAccessed = new Date().getTime(); existingServer.LastConnectionMode = MediaBrowser.ConnectionMode.Manual; apiClient.serverInfo(existingServer); @@ -228,6 +228,7 @@ var credentials = credentialProvider.credentials(); server.DateLastAccessed = new Date().getTime(); + server.Id = result.ServerId; if (saveCredentials) { server.UserId = result.User.Id; @@ -666,12 +667,16 @@ var servers = foundServers.map(function (foundServer) { - return { + var info = { Id: foundServer.Id, LocalAddress: foundServer.Address, Name: foundServer.Name, ManualAddress: convertEndpointAddressToManualAddress(foundServer) }; + + info.LastConnectionMode = info.ManualAddress ? MediaBrowser.ConnectionMode.Manual : MediaBrowser.ConnectionMode.Local; + + return info; }); deferred.resolveWith(null, [servers]); }); @@ -1117,7 +1122,7 @@ }); function onDone() { - + credentials = credentialProvider.credentials(); credentials.servers = credentials.servers.filter(function (s) { diff --git a/dashboard-ui/thirdparty/apiclient/credentials.js b/dashboard-ui/thirdparty/apiclient/credentials.js index 656c52f82..247aa7622 100644 --- a/dashboard-ui/thirdparty/apiclient/credentials.js +++ b/dashboard-ui/thirdparty/apiclient/credentials.js @@ -48,6 +48,10 @@ self.addOrUpdateServer = function (list, server) { + if (!server.Id) { + throw new Error('Server.Id cannot be null or empty'); + } + var existing = list.filter(function (s) { return s.Id == server.Id; })[0]; @@ -76,9 +80,15 @@ if (server.WakeOnLanInfos && server.WakeOnLanInfos.length) { existing.WakeOnLanInfos = server.WakeOnLanInfos; } + if (server.LastConnectionMode != null) { + existing.LastConnectionMode = server.LastConnectionMode; + } + + return existing; } else { list.push(server); + return server; } }; };