From 8c248c229a55705f4f572e5241a4b7894ec7eb52 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 5 Sep 2015 17:15:36 -0400 Subject: [PATCH] update bitrate detection --- dashboard-ui/apiclient/apiclient.js | 2 +- dashboard-ui/channelitems.html | 9 ------ .../cordova/android/androidcredentials.js | 6 ++-- dashboard-ui/scripts/appsettings.js | 16 ++++++++++ dashboard-ui/scripts/channelitems.js | 21 ------------ dashboard-ui/scripts/librarybrowser.js | 12 +++---- dashboard-ui/scripts/mediaplayer.js | 32 +++++++++++++++++-- .../scripts/mypreferenceslanguages.js | 18 +++++++++-- .../strings/javascript/javascript.json | 1 + .../thirdparty/paper-button-style.css | 4 +++ 10 files changed, 77 insertions(+), 44 deletions(-) diff --git a/dashboard-ui/apiclient/apiclient.js b/dashboard-ui/apiclient/apiclient.js index a4250f07c9..e4356264de 100644 --- a/dashboard-ui/apiclient/apiclient.js +++ b/dashboard-ui/apiclient/apiclient.js @@ -528,7 +528,7 @@ // First try a small amount so that we don't hang up their mobile connection self.getDownloadSpeed(1000000).done(function (bitrate) { - if (bitrate < 3000000) { + if (bitrate < 1000000) { deferred.resolveWith(null, [Math.round(bitrate * .8)]); } else { diff --git a/dashboard-ui/channelitems.html b/dashboard-ui/channelitems.html index 0b3c7d535e..37c05e0a1e 100644 --- a/dashboard-ui/channelitems.html +++ b/dashboard-ui/channelitems.html @@ -19,19 +19,10 @@
-
- -
- - -
- -
diff --git a/dashboard-ui/cordova/android/androidcredentials.js b/dashboard-ui/cordova/android/androidcredentials.js index 21beec983b..7e6e744e4b 100644 --- a/dashboard-ui/cordova/android/androidcredentials.js +++ b/dashboard-ui/cordova/android/androidcredentials.js @@ -43,8 +43,10 @@ function sendRequest(request) { + var method = request.type || "GET"; + // For now, we can only handle json responses - if (request.dataType) { + if (request.dataType || method == "GET") { if (request.dataType != 'json') { return baseAjaxMethod(request); } @@ -68,7 +70,7 @@ } var javaRequest = { - Method: request.type || "GET", + Method: method, Url: request.url, RequestHeaders: request.headers }; diff --git a/dashboard-ui/scripts/appsettings.js b/dashboard-ui/scripts/appsettings.js index 2506fa2d04..5500396e7c 100644 --- a/dashboard-ui/scripts/appsettings.js +++ b/dashboard-ui/scripts/appsettings.js @@ -8,6 +8,22 @@ window.AppSettings = { + enableAutomaticBitrateDetection: function (val) { + + if (val != null) { + update('enableAutomaticBitrateDetection', val.toString()); + } + + var savedVal = appStorage.getItem('enableAutomaticBitrateDetection'); + + if (!savedVal) { + if (AppInfo.isNativeApp) { + //return false; + } + } + + return appStorage.getItem('enableAutomaticBitrateDetection') != 'false'; + }, maxStreamingBitrate: function (val) { if (val != null) { diff --git a/dashboard-ui/scripts/channelitems.js b/dashboard-ui/scripts/channelitems.js index d27e618e58..ba95aad294 100644 --- a/dashboard-ui/scripts/channelitems.js +++ b/dashboard-ui/scripts/channelitems.js @@ -11,20 +11,6 @@ StartIndex: 0 }; - function getPageSizes() { - - var sizes = []; - - if (!maxPageSize || maxPageSize >= 10) sizes.push(10); - if (!maxPageSize || maxPageSize >= 20) sizes.push(20); - if (!maxPageSize || maxPageSize >= 30) sizes.push(30); - if (!maxPageSize || maxPageSize >= 40) sizes.push(40); - if (!maxPageSize || maxPageSize >= 50) sizes.push(50); - if (!maxPageSize || maxPageSize >= 100) sizes.push(100); - - return sizes; - } - function getSavedQueryId() { return 'channels-1-' + getParameterByName('id') + (getParameterByName('folderId') || ''); } @@ -198,7 +184,6 @@ }).checkboxradio('refresh'); $('.alphabetPicker', page).alphaValue(query.NameStartsWith); - $('#selectPageSize', page).val(query.Limit); } $(document).on('pageinit', "#channelItemsPage", function () { @@ -248,12 +233,6 @@ reloadItems(page); }); - $('#selectPageSize', page).on('change', function () { - query.Limit = parseInt(this.value); - query.StartIndex = 0; - reloadItems(page); - }); - }).on('pagebeforeshow', "#channelItemsPage", function () { var page = this; diff --git a/dashboard-ui/scripts/librarybrowser.js b/dashboard-ui/scripts/librarybrowser.js index 733c4c9a30..0b5507a4d8 100644 --- a/dashboard-ui/scripts/librarybrowser.js +++ b/dashboard-ui/scripts/librarybrowser.js @@ -2540,24 +2540,24 @@ if (showControls) { - html += ''; - html += '= totalRecordCount ? 'disabled' : '') + '>'; + html += ''; + html += '= totalRecordCount ? 'disabled' : '') + '>'; } html += (options.additionalButtonsHtml || ''); if (options.addSelectionButton) { - html += ''; + html += ''; } if (options.addLayoutButton) { - html += ''; + html += ''; } if (options.sortButton) { - html += ''; + html += ''; } if (options.viewButton) { @@ -2565,7 +2565,7 @@ //html += ''; var viewPanelClass = options.viewPanelClass || 'viewPanel'; var title = options.viewIcon == 'filter-list' ? Globalize.translate('ButtonFilter') : Globalize.translate('ButtonMenu'); - html += ''; + html += ''; } html += '
'; diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 6151280d69..03d8381088 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -451,6 +451,10 @@ Format: 'pgssub', Method: 'Embed' }); + profile.SubtitleProfiles.push({ + Format: 'dvdsub', + Method: 'Embed' + }); profile.SubtitleProfiles.push({ Format: 'vtt', Method: 'Embed' @@ -988,6 +992,8 @@ }; }; + var lastBitrateDetect = 0; + self.playInternal = function (item, startPosition, callback) { if (item == null) { @@ -1008,7 +1014,28 @@ return; } - var deviceProfile = self.getDeviceProfile(); + if (item.MediaType == 'Video' && AppSettings.enableAutomaticBitrateDetection() && (new Date().getTime() - lastBitrateDetect) > 1000) { + + Dashboard.showModalLoadingMsg(); + + ApiClient.detectBitrate().done(function (bitrate) { + + Logger.log('Max bitrate auto detected to ' + bitrate); + lastBitrateDetect = new Date().getTime(); + AppSettings.maxStreamingBitrate(bitrate); + + playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback); + }).fail(function () { + + playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback); + }); + + } else { + playOnDeviceProfileCreated(self.getDeviceProfile(), item, startPosition, callback); + } + }; + + function playOnDeviceProfileCreated(deviceProfile, item, startPosition, callback) { if (item.MediaType === "Video") { @@ -1040,9 +1067,8 @@ MediaController.showPlaybackInfoErrorMessage('NoCompatibleStream'); } } - }); - }; + } function playInternalPostMediaSourceSelection(item, mediaSource, startPosition, callback) { diff --git a/dashboard-ui/scripts/mypreferenceslanguages.js b/dashboard-ui/scripts/mypreferenceslanguages.js index 749a702cc9..a3bea988d1 100644 --- a/dashboard-ui/scripts/mypreferenceslanguages.js +++ b/dashboard-ui/scripts/mypreferenceslanguages.js @@ -39,8 +39,16 @@ return ''; }).join(''); - $('#selectMaxBitrate', page).html(bitrateOptions).val(AppSettings.maxStreamingBitrate()); + bitrateOptions = '' + bitrateOptions; + + $('#selectMaxBitrate', page).html(bitrateOptions); + + if (AppSettings.enableAutomaticBitrateDetection()) { + $('#selectMaxBitrate', page).val(''); + } else { + $('#selectMaxBitrate', page).val(AppSettings.maxStreamingBitrate()); + } $('#selectMaxChromecastBitrate', page).val(AppSettings.maxChromecastBitrate()); @@ -100,7 +108,13 @@ AppSettings.enableExternalPlayers(page.querySelector('.chkExternalVideoPlayer').checked); - AppSettings.maxStreamingBitrate($('#selectMaxBitrate', page).val()); + if ($('#selectMaxBitrate', page).val()) { + AppSettings.maxStreamingBitrate($('#selectMaxBitrate', page).val()); + AppSettings.enableAutomaticBitrateDetection(false); + } else { + AppSettings.enableAutomaticBitrateDetection(true); + } + AppSettings.maxChromecastBitrate($('#selectMaxChromecastBitrate', page).val()); AppSettings.enableChromecastAc3(page.querySelector('.chkEnableChromecastAc3').checked); diff --git a/dashboard-ui/strings/javascript/javascript.json b/dashboard-ui/strings/javascript/javascript.json index e992e7bebd..60df188cd6 100644 --- a/dashboard-ui/strings/javascript/javascript.json +++ b/dashboard-ui/strings/javascript/javascript.json @@ -40,6 +40,7 @@ "TitleLiveTV": "Live TV", "ButtonCancelSyncJob": "Cancel sync job", "TitleSync": "Sync", + "OptionAutomatic": "Auto", "HeaderSelectDate": "Select Date", "ButtonDonate": "Donate", "LabelRecurringDonationCanBeCancelledHelp": "Recurring donations can be cancelled at any time from within your PayPal account.", diff --git a/dashboard-ui/thirdparty/paper-button-style.css b/dashboard-ui/thirdparty/paper-button-style.css index 52052f08f6..c05d528452 100644 --- a/dashboard-ui/thirdparty/paper-button-style.css +++ b/dashboard-ui/thirdparty/paper-button-style.css @@ -242,6 +242,10 @@ paper-icon-button paper-ripple { color: inherit !important; } +.ui-page-theme-b paper-icon-button[disabled] { + color: #444 !important; +} + paper-dialog + iron-overlay-backdrop { background-color: transparent !important; }