diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index b4b15e587e..e1409bc774 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -98,7 +98,7 @@ $(this).off('ended.playnext'); - self.queuePlayNext(); + self.nextTrack(); } function startProgressInterval(itemId) { @@ -991,7 +991,7 @@ }); }; - self.queuePlayNext = function () { + self.nextTrack = function () { var newIndex = currentPlaylistIndex + 1; var newItem = self.playlist[newIndex]; @@ -1004,6 +1004,21 @@ }); } }; + + self.previousTrack = function () { + var newIndex = currentPlaylistIndex - 1; + if (newIndex >= 0) { + var newItem = self.playlist[newIndex]; + + if (newItem) { + Dashboard.getCurrentUser().done(function (user) { + + self.playInternal(newItem, 0, user); + currentPlaylistIndex = newIndex; + }); + } + } + }; self.queueItem = function (item) { @@ -1048,6 +1063,10 @@ currentMediaElement.play(); }; + self.seek = function (position) { + currentMediaElement.currentTime = position / (1000 * 10000); + }; + self.mute = function () { currentMediaElement.volume = 0; }; diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 92b435e8f7..5e027e9eab 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -791,7 +791,24 @@ var Dashboard = { } else if (msg.MessageType === "Playstate") { - + if (msg.Data.Command === 'Stop') { + MediaPlayer.stop(); + } + else if (msg.Data.Command === 'Pause') { + MediaPlayer.pause(); + } + else if (msg.Data.Command === 'Unpause') { + MediaPlayer.unpause(); + } + else if (msg.Data.Command === 'Seek') { + MediaPlayer.seek(msg.Data.SeekPosition); + } + else if (msg.Data.Command === 'NextTrack') { + MediaPlayer.nextTrack(); + } + else if (msg.Data.Command === 'PreviousTrack') { + MediaPlayer.previousTrack(); + } } },