diff --git a/ApiClient.js b/ApiClient.js index b1c4a7a63..637e2e549 100644 --- a/ApiClient.js +++ b/ApiClient.js @@ -3271,6 +3271,24 @@ MediaBrowser.ApiClient = function ($, navigator, JSON, WebSocket, setTimeout) { url: url }); }; + + self.sendPlayStateCommand = function (sessionId, command, options) { + + if (!sessionId) { + throw new Error("null sessionId"); + } + + if (!command) { + throw new Error("null command"); + } + + var url = self.getUrl("Sessions/" + sessionId + "/Playing/" + command, options || {}); + + return self.ajax({ + type: "POST", + url: url + }); + }; } }(jQuery, navigator, window.JSON, window.WebSocket, setTimeout); diff --git a/dashboard-ui/scripts/remotecontrol.js b/dashboard-ui/scripts/remotecontrol.js index a6b4ab7b1..2703d65ff 100644 --- a/dashboard-ui/scripts/remotecontrol.js +++ b/dashboard-ui/scripts/remotecontrol.js @@ -682,6 +682,63 @@ }); } + + $('.btnStop', popup).on('click', function () { + + var id = $('#selectSession', popup).val(); + + ApiClient.sendPlayStateCommand(id, 'Stop'); + }); + + $('.btnPause', popup).on('click', function () { + + var id = $('#selectSession', popup).val(); + + ApiClient.sendPlayStateCommand(id, 'Pause'); + }); + + $('.btnPlay', popup).on('click', function () { + + var id = $('#selectSession', popup).val(); + + ApiClient.sendPlayStateCommand(id, 'Unpause'); + }); + + $('.btnNextTrack', popup).on('click', function () { + + var id = $('#selectSession', popup).val(); + + ApiClient.sendPlayStateCommand(id, 'NextTrack'); + }); + + $('.btnPreviousTrack', popup).on('click', function () { + + var id = $('#selectSession', popup).val(); + + ApiClient.sendPlayStateCommand(id, 'PreviousTrack'); + }); + + $("#positionSlider", popup).on("slidestart", function () { + + this.isSliding = true; + + }).on("slidestop", function () { + + var id = $('#selectSession', popup).val(); + + var percent = $(this).val(); + + var duration = parseInt($(this).attr('data-duration')); + + var position = duration * percent / 100; + + ApiClient.sendPlayStateCommand(id, 'Seek', + { + SeekPosition: parseInt(position) + }); + + this.isSliding = false; + }); } function getPlaybackHtml() { @@ -700,7 +757,7 @@ html += ''; html += ''; - html += ''; + html += ''; html += ''; html += '
'; @@ -757,11 +814,11 @@ type: 'Primary', tag: item.PrimaryImageTag }); - + if (!img || img.src.toLowerCase().indexOf(imgUrl.toLowerCase()) == -1) { imageContainer.html(''); } - + } else { imageContainer.hide(); } @@ -771,7 +828,13 @@ var percent = duration ? 100 * time / duration : 0; - $('#positionSlider', elem).val(percent).slider('refresh'); + var slider = $('#positionSlider', elem); + + if (!slider[0].isSliding) { + slider.val(percent).slider('refresh'); + } + + slider.attr('data-duration', duration); $('.nowPlayingTime', elem).html(Dashboard.getDisplayTime(time)); $('.duration', elem).html(Dashboard.getDisplayTime(duration)); diff --git a/packages.config b/packages.config index d09b4a2cd..5dd14404a 100644 --- a/packages.config +++ b/packages.config @@ -1,6 +1,6 @@  - + \ No newline at end of file