diff --git a/samples/dash-if-reference-player/app/css/main.css b/samples/dash-if-reference-player/app/css/main.css index 913e5fdcb1..e021400bb4 100644 --- a/samples/dash-if-reference-player/app/css/main.css +++ b/samples/dash-if-reference-player/app/css/main.css @@ -689,6 +689,10 @@ BS Information border-left-color: #5cb85c ; } +.bs-callout-warning { + border-left-color: #f0ad4e ; +} + .bs-callout-danger { border-left-color: #CA0B00; } diff --git a/samples/dash-if-reference-player/app/main.js b/samples/dash-if-reference-player/app/main.js index 7c921b9b9a..22e4f6a30c 100644 --- a/samples/dash-if-reference-player/app/main.js +++ b/samples/dash-if-reference-player/app/main.js @@ -233,6 +233,20 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' $scope.conformanceViolations = []; + var defaultExternalSettings = { + mpd: encodeURIComponent('https://dash.akamaized.net/akamai/bbb_30fps/bbb_30fps.mpd'), + loop: true, + autoPlay: true, + drmToday: false, + forceQualitySwitchSelected: false, + drmPrioritiesEnabled: false, + languageAudio: null, + roleVideo: null, + languageText: null, + roleText: undefined, + forceTextStreaming: false + } + // metrics $scope.videoBitrate = 0; $scope.videoIndex = 0; @@ -313,6 +327,8 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' // store a ref in window.player to provide an easy way to play with dash.js API window.player = $scope.player = dashjs.MediaPlayer().create(); /* jshint ignore:line */ + const defaultSettings = JSON.parse(JSON.stringify($scope.player.getSettings())); + $scope.player.on(dashjs.MediaPlayer.events.ERROR, function (e) { /* jshint ignore:line */ console.log(e); if (!e.event) { @@ -1414,18 +1430,21 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' /** Copy a URL containing the current settings as query Parameters to the Clipboard */ $scope.copyQueryUrl = function () { - var externalSettingsString = 'mpd=' + encodeURIComponent(decodeURIComponent($scope.selectedItem.url)) - + '&loop=' + $scope.loopSelected - + '&autoPlay=' + $scope.autoPlaySelected - + '&drmToday=' + $scope.drmToday - + '&forceQualitySwitchSelected=' + $scope.forceQualitySwitchSelected - + '&drmPrioritiesEnabled=' + $scope.prioritiesEnabled - + '&languageAudio=' + $scope.initialSettings.audio - + '&roleVideo=' + $scope.initialSettings.video - + '&languageText=' + $scope.initialSettings.text - + '&roleText=' + $scope.initialSettings.textRole - + '&forceTextStreaming=' + $scope.initialSettings.forceTextStreaming - + '&'; + var currentExternalSettings = { + mpd: encodeURIComponent(decodeURIComponent($scope.selectedItem.url)), + loop: $scope.loopSelected, + autoPlay: $scope.autoPlaySelected, + drmToday: $scope.drmToday, + forceQualitySwitchSelected: $scope.forceQualitySwitchSelected, + drmPrioritiesEnabled: $scope.prioritiesEnabled, + languageAudio: $scope.initialSettings.audio, + roleVideo: $scope.initialSettings.video, + languageText: $scope.initialSettings.text, + roleText: $scope.textRole, + forceTextStreaming: $scope.initialSettings.forceTextStreaming + } + + var externalSettingsString = $scope.toQueryString($scope.makeSettingDifferencesObject(currentExternalSettings, defaultExternalSettings)); $scope.handleRequestHeaders(); $scope.handleClearkeys(); @@ -1436,25 +1455,29 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' switch (drm.drmKeySystem) { case 'com.microsoft.playready': currentDrm = { 'playready': drm }; - externalSettingsString += $scope.toQueryString(currentDrm) + '&'; + externalSettingsString += '&' + $scope.toQueryString(currentDrm); break; case 'com.widevine.alpha': currentDrm = { 'widevine': drm }; - externalSettingsString += $scope.toQueryString(currentDrm) + '&'; + externalSettingsString += '&' + $scope.toQueryString(currentDrm); break; case 'org.w3.clearkey': currentDrm = { 'clearkey': drm }; - externalSettingsString += $scope.toQueryString(currentDrm) + '&'; + externalSettingsString += '&' + $scope.toQueryString(currentDrm); break; } } } var currentSetting = $scope.player.getSettings(); + currentSetting = $scope.makeSettingDifferencesObject(currentSetting, defaultSettings); + var url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?'; - var queryString = externalSettingsString + $scope.toQueryString(currentSetting); + var queryString = externalSettingsString + '+&' + $scope.toQueryString(currentSetting); var urlString = url + queryString; + if (urlString.slice(-1) === '&') urlString = urlString.slice(0, -1); + $scope.checkQueryLength(urlString); const element = document.createElement('textarea'); @@ -1465,6 +1488,57 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' document.body.removeChild(element); } + $scope.makeSettingDifferencesObject = function (settings, defaultSettings) { + var settingDifferencesObject = {}; + + if (Array.isArray(settings)) { + console.log(settings) + return _arraysEqual(settings, defaultSettings) ? {} : settings; + } + + for (var setting in settings) { + if (typeof defaultSettings[setting] === 'object' && defaultSettings[setting] !== null && !(defaultSettings[setting] instanceof Array)) { + settingDifferencesObject[setting] = this.makeSettingDifferencesObject(settings[setting], defaultSettings[setting], false); + } + else if(settings[setting] !== defaultSettings[setting]){ + if(Array.isArray(settings[setting])){ + settingDifferencesObject[setting] = _arraysEqual(settings[setting], defaultSettings[setting]) ? {} : settings[setting]; + } + else { + settingDifferencesObject[setting] = settings[setting]; + } + + } + } + + return settingDifferencesObject; + } + + function _arraysEqual(a, b) { + if (a === b) { + return true; + } + if (a == null || b == null) { + return false; + } + if (a.length !== b.length) { + return false; + } + + // If you don't care about the order of the elements inside + // the array, you should sort both arrays here. + // Please note that calling sort on an array will modify that array. + // you might want to clone your array first. + + for (var i = 0; i < a.length; ++i) { + if (a[i] !== b[i]) { + return false; + } + } + + return true; + } + /** Transform the current Settings into a nested query-string format */ $scope.toQueryString = function (settings, prefix) { var urlString = []; @@ -1478,7 +1552,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' } } // Make the string, then remove all cases of && caused by empty settings - return urlString.join('&').split('&&').join('&'); + return urlString.join('&').split(/&&*/).join('&'); } /** Resolve nested query parameters */ @@ -1620,9 +1694,10 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' var [key, value] = handleExternalSettings[index].split('=') || ''; switch (key) { case 'mpd': - $scope.selectedItem.url = decodeURIComponent(value); + $scope.selectedItem.url = decodeURIComponent(value).slice(0, -1); + break; case 'loop': - $scope.loopSelected = $scope.parseBoolean(value); + $scope.loopSelected = this.parseBoolean(value); break; case 'autoPlay': $scope.autoPlaySelected = this.parseBoolean(value); @@ -1672,7 +1747,7 @@ app.controller('DashController', ['$scope', '$window', 'sources', 'contributors' if (!currentQuery.includes('&')) { return; } - var passedSettings = currentQuery.slice(currentQuery.indexOf('debug')); + var passedSettings = currentQuery.slice(currentQuery.indexOf('+')).substring(1); passedSettings = $scope.toSettingsObject(passedSettings)[0]; $scope.protectionData = $scope.toSettingsObject(currentQuery)[1]; $scope.player.updateSettings(passedSettings); diff --git a/samples/dash-if-reference-player/index.html b/samples/dash-if-reference-player/index.html index 9c0dcb05b2..2a521e71ed 100644 --- a/samples/dash-if-reference-player/index.html +++ b/samples/dash-if-reference-player/index.html @@ -131,12 +131,12 @@ ng-cloak>{{getOptionsButtonLabel()}} - +
-
URL Copied!
+
URL Copied!
@@ -199,14 +199,16 @@
@@ -247,19 +249,22 @@
@@ -295,13 +300,15 @@
@@ -312,24 +319,29 @@
@@ -600,12 +612,14 @@
@@ -615,7 +629,8 @@
@@ -626,9 +641,11 @@
Live delay
- + - +
- + - + - + @@ -665,12 +685,14 @@ ng-model="initialSettings.textRole" ng-change="updateInitialRoleText()"> @@ -682,26 +704,32 @@ @@ -713,37 +741,43 @@ @@ -759,32 +793,40 @@ Enable CMCD Reporting - + - + - + - + - - + +
@@ -848,12 +890,13 @@
-
-
NewExport settings
- Try out our new "export settings" feature and share your current dash.js settings and DRM parameters easily via URL query parameters. - Click on "Copy Settings URL" on the top right and paste the URL in the address bar of your browser. +
+
UpdatedExport settings
+ Our export settings feature creates smaller URLs now. + Click on "Copy Settings URL" on the top right and paste the URL in the address bar of your browser. The + current settings are compared to the default settings and the difference is stored using query parameters.