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 += '