From 6c735c55a95cc7796ca4f105721b6a0672dd7a4e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 27 Oct 2016 13:29:40 -0400 Subject: [PATCH] fix remote control stopping playback --- .../emby-webcomponents/.bower.json | 8 ++--- .../emby-webcomponents/backdrop/backdrop.js | 6 ++-- .../emby-slider/emby-slider.js | 30 ++++++++++++----- .../emby-webcomponents/thememediaplayer.js | 12 +++---- dashboard-ui/components/chromecasthelpers.js | 1 + .../libraryoptionseditor.template.html | 2 +- dashboard-ui/scripts/chromecast.js | 33 ++++++++++--------- dashboard-ui/scripts/mediacontroller.js | 30 +++++++++-------- dashboard-ui/scripts/mediaplayer.js | 14 ++++---- dashboard-ui/scripts/remotecontrol.js | 4 +-- dashboard-ui/scripts/site.js | 4 +-- 11 files changed, 84 insertions(+), 60 deletions(-) diff --git a/dashboard-ui/bower_components/emby-webcomponents/.bower.json b/dashboard-ui/bower_components/emby-webcomponents/.bower.json index 1a920134b8..a39225014b 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/.bower.json +++ b/dashboard-ui/bower_components/emby-webcomponents/.bower.json @@ -14,12 +14,12 @@ }, "devDependencies": {}, "ignore": [], - "version": "1.4.324", - "_release": "1.4.324", + "version": "1.4.325", + "_release": "1.4.325", "_resolution": { "type": "version", - "tag": "1.4.324", - "commit": "65e5d919b19f4b447aee6914ee8c40347c4e98ff" + "tag": "1.4.325", + "commit": "f11f822888ef812064c9a2677dc5c639e82cbb9f" }, "_source": "https://github.com/MediaBrowser/emby-webcomponents.git", "_target": "^1.2.1", diff --git a/dashboard-ui/bower_components/emby-webcomponents/backdrop/backdrop.js b/dashboard-ui/bower_components/emby-webcomponents/backdrop/backdrop.js index 57b19ce5e1..a72db2fcc8 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/backdrop/backdrop.js +++ b/dashboard-ui/bower_components/emby-webcomponents/backdrop/backdrop.js @@ -310,8 +310,10 @@ function setBackdrop(url) { - if (typeof url !== 'string') { - url = getImageUrls([url])[0]; + if (url) { + if (typeof url !== 'string') { + url = getImageUrls([url])[0]; + } } if (url) { diff --git a/dashboard-ui/bower_components/emby-webcomponents/emby-slider/emby-slider.js b/dashboard-ui/bower_components/emby-webcomponents/emby-slider/emby-slider.js index 3cb6d56cb1..648b06b15a 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/emby-slider/emby-slider.js +++ b/dashboard-ui/bower_components/emby-webcomponents/emby-slider/emby-slider.js @@ -71,6 +71,13 @@ dom.addEventListener(this, 'input', function (e) { this.dragging = true; + + updateBubble(this, this.value, sliderBubble); + + if (hasHideClass) { + sliderBubble.classList.remove('hide'); + hasHideClass = false; + } }, { passive: true }); @@ -78,6 +85,10 @@ dom.addEventListener(this, 'change', function () { this.dragging = false; updateValues(this, backgroundLower, backgroundUpper); + + sliderBubble.classList.add('hide'); + hasHideClass = true; + }, { passive: true }); @@ -86,16 +97,19 @@ if (!browser.firefox) { dom.addEventListener(this, 'mousemove', function (e) { - var rect = this.getBoundingClientRect(); - var clientX = e.clientX; - var bubbleValue = (clientX - rect.left) / rect.width; - bubbleValue *= 100; - updateBubble(this, Math.round(bubbleValue), sliderBubble); + if (!this.dragging) { + var rect = this.getBoundingClientRect(); + var clientX = e.clientX; + var bubbleValue = (clientX - rect.left) / rect.width; + bubbleValue *= 100; + updateBubble(this, Math.round(bubbleValue), sliderBubble); - if (hasHideClass) { - sliderBubble.classList.remove('hide'); - hasHideClass = false; + if (hasHideClass) { + sliderBubble.classList.remove('hide'); + hasHideClass = false; + } } + }, { passive: true }); diff --git a/dashboard-ui/bower_components/emby-webcomponents/thememediaplayer.js b/dashboard-ui/bower_components/emby-webcomponents/thememediaplayer.js index 15b8b8203d..8252edd4ba 100644 --- a/dashboard-ui/bower_components/emby-webcomponents/thememediaplayer.js +++ b/dashboard-ui/bower_components/emby-webcomponents/thememediaplayer.js @@ -14,17 +14,17 @@ define(['playbackManager', 'userSettings'], function (playbackManager, userSetti return; } - currentThemeIds = items.map(function (i) { - return i.Id; - }); - - currentOwnerId = ownerId; - if (enabled(items[0].MediaType)) { + currentThemeIds = items.map(function (i) { + return i.Id; + }); + playbackManager.play({ items: items, fullscreen: false, enableRemotePlayers: false + }).then(function () { + currentOwnerId = ownerId; }); } diff --git a/dashboard-ui/components/chromecasthelpers.js b/dashboard-ui/components/chromecasthelpers.js index 990e5d673a..0dae48cdf8 100644 --- a/dashboard-ui/components/chromecasthelpers.js +++ b/dashboard-ui/components/chromecasthelpers.js @@ -214,6 +214,7 @@ parse: function (text) { var links = []; + var match; while (match = linkRegExp.exec(text)) { // console.log(matches); diff --git a/dashboard-ui/components/libraryoptionseditor/libraryoptionseditor.template.html b/dashboard-ui/components/libraryoptionseditor/libraryoptionseditor.template.html index 3f4b9a303a..e6aeb9a22f 100644 --- a/dashboard-ui/components/libraryoptionseditor/libraryoptionseditor.template.html +++ b/dashboard-ui/components/libraryoptionseditor/libraryoptionseditor.template.html @@ -1,7 +1,7 @@ 

${HeaderSettings}

${LabelDownloadInternetMetadataHelp}
diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index 25a3be881f..3ac9a14e80 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -315,7 +315,7 @@ if (!this.session) { console.log("no session"); - return; + return Promise.reject(); } // Convert the items to smaller stubs to send the minimal amount of information @@ -330,7 +330,7 @@ }; }); - this.sendMessage({ + return this.sendMessage({ options: options, command: command }); @@ -359,11 +359,15 @@ message.maxBitrate = bitrateSetting; } - require(['chromecasthelpers'], function (chromecasthelpers) { + return new Promise(function (resolve, reject) { - chromecasthelpers.getServerAddress(ApiClient).then(function (serverAddress) { - message.serverAddress = serverAddress; - player.sendMessageInternal(message); + require(['chromecasthelpers'], function (chromecasthelpers) { + + chromecasthelpers.getServerAddress(ApiClient).then(function (serverAddress) { + message.serverAddress = serverAddress; + player.sendMessageInternal(message).then(resolve, reject); + + }, reject); }); }); }; @@ -374,6 +378,7 @@ //console.log(message); this.session.sendMessage(messageNamespace, message, this.onPlayCommandSuccess.bind(this), this.errorHandler); + return Promise.resolve(); }; CastPlayer.prototype.onPlayCommandSuccess = function () { @@ -541,22 +546,22 @@ self.play = function (options) { - Dashboard.getCurrentUser().then(function (user) { + return Dashboard.getCurrentUser().then(function (user) { if (options.items) { - self.playWithCommand(options, 'PlayNow'); + return self.playWithCommand(options, 'PlayNow'); } else { - self.getItemsForPlayback({ + return self.getItemsForPlayback({ Ids: options.ids.join(',') }).then(function (result) { options.items = result.Items; - self.playWithCommand(options, 'PlayNow'); + return self.playWithCommand(options, 'PlayNow'); }); } @@ -568,16 +573,14 @@ self.playWithCommand = function (options, command) { if (!options.items) { - ApiClient.getItem(Dashboard.getCurrentUserId(), options.ids[0]).then(function (item) { + return ApiClient.getItem(Dashboard.getCurrentUserId(), options.ids[0]).then(function (item) { options.items = [item]; - self.playWithCommand(options, command); + return self.playWithCommand(options, command); }); - - return; } - castPlayer.loadMedia(options, command); + return castPlayer.loadMedia(options, command); }; self.unpause = function () { diff --git a/dashboard-ui/scripts/mediacontroller.js b/dashboard-ui/scripts/mediacontroller.js index 832f6367bc..f64da35840 100644 --- a/dashboard-ui/scripts/mediacontroller.js +++ b/dashboard-ui/scripts/mediacontroller.js @@ -460,22 +460,24 @@ }); }; - function doWithPlaybackValidation(player, fn) { + function validatePlayback(player) { if (!player.isLocalPlayer) { - fn(); - return; + return Promise.resolve(); } - requirejs(["registrationServices"], function (registrationServices) { + return new Promise(function (resolve, reject) { - self.playbackTimeLimitMs = null; + requirejs(["registrationServices"], function (registrationServices) { - registrationServices.validateFeature('playback').then(fn, function () { + self.playbackTimeLimitMs = null; - self.playbackTimeLimitMs = lockedTimeLimitMs; - startAutoStopTimer(); - fn(); + registrationServices.validateFeature('playback').then(resolve, function () { + + self.playbackTimeLimitMs = lockedTimeLimitMs; + startAutoStopTimer(); + resolve(); + }); }); }); } @@ -525,16 +527,16 @@ if (options.enableRemotePlayers === false) { if (!currentPlayer.isLocalPlayer) { - return; + return Promise.reject(); } } - doWithPlaybackValidation(currentPlayer, function () { + return validatePlayback(currentPlayer).then(function () { if (typeof (options) === 'string') { options = { ids: [options] }; } - currentPlayer.play(options); + return currentPlayer.play(options); }); }; @@ -545,7 +547,7 @@ id = id.Id; } - doWithPlaybackValidation(currentPlayer, function () { + validatePlayback(currentPlayer).then(function () { currentPlayer.shuffle(id); }); }; @@ -557,7 +559,7 @@ id = id.Id; } - doWithPlaybackValidation(currentPlayer, function () { + validatePlayback(currentPlayer).then(function () { currentPlayer.instantMix(id); }); }; diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 05c499b5e3..5ca193a704 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -434,26 +434,26 @@ define(['appSettings', 'userSettings', 'appStorage', 'datetime'], function (appS Dashboard.showLoadingMsg(); - Dashboard.getCurrentUser().then(function (user) { + return Dashboard.getCurrentUser().then(function (user) { if (options.items) { - translateItemsForPlayback(options.items, true).then(function (items) { + return translateItemsForPlayback(options.items, true).then(function (items) { - self.playWithIntros(items, options, user); + return self.playWithIntros(items, options, user); }); } else { - self.getItemsForPlayback({ + return self.getItemsForPlayback({ Ids: options.ids.join(',') }).then(function (result) { - translateItemsForPlayback(result.Items, true).then(function (items) { + return translateItemsForPlayback(result.Items, true).then(function (items) { - self.playWithIntros(items, options, user); + return self.playWithIntros(items, options, user); }); }); @@ -489,6 +489,8 @@ define(['appSettings', 'userSettings', 'appStorage', 'datetime'], function (appS }); }); + // Todo: rework above methods to use promises + return Promise.resolve(); }; function getOptimalMediaSource(mediaType, versions) { diff --git a/dashboard-ui/scripts/remotecontrol.js b/dashboard-ui/scripts/remotecontrol.js index 3ab28e217b..2adbadec08 100644 --- a/dashboard-ui/scripts/remotecontrol.js +++ b/dashboard-ui/scripts/remotecontrol.js @@ -19,7 +19,7 @@ remoteOptions.startPositionTicks = options.startPositionTicks; } - ApiClient.sendPlayCommand(sessionId, remoteOptions); + return ApiClient.sendPlayCommand(sessionId, remoteOptions); } function sendPlayStateCommand(command, options) { @@ -57,7 +57,7 @@ self.play = function (options) { - sendPlayCommand(options, 'PlayNow'); + return sendPlayCommand(options, 'PlayNow'); }; self.shuffle = function (id) { diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index a3b3336054..1759bcb4f7 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -1441,11 +1441,11 @@ var AppInfo = {}; if (options.fullscreen === false) { // theme backdrops - not supported if (!options.items || options.items[0].MediaType == 'Video') { - return; + return Promise.reject(); } } - MediaController.play(options); + return MediaController.play(options); }, queue: function (options) {