From 673548b63084e25e7313660bee44d2074d77949c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Alm=C3=A1nzar?= Date: Wed, 17 Jul 2013 23:18:16 -0400 Subject: [PATCH 1/2] respond to playstate commands play/pause/stop/seek/nexttrack --- dashboard-ui/scripts/mediaplayer.js | 4 ++++ dashboard-ui/scripts/site.js | 18 +++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index 36bf0595eb..b68e5b2c6a 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -1048,6 +1048,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 846209366d..8043391597 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -791,7 +791,23 @@ 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.queuePlayNext(); + } + else if (msg.Data.Command === 'PreviousTrack') { + } } }, From 47a6b2c0ae0c8dfe31c5e1cb7f7b5fe0396b6856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Miguel=20Alm=C3=A1nzar?= Date: Thu, 18 Jul 2013 23:12:52 -0400 Subject: [PATCH 2/2] finish #386 and implement nextTrack action --- dashboard-ui/scripts/mediaplayer.js | 19 +++++++++++++++++-- dashboard-ui/scripts/site.js | 3 ++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/dashboard-ui/scripts/mediaplayer.js b/dashboard-ui/scripts/mediaplayer.js index b68e5b2c6a..898094a3b6 100644 --- a/dashboard-ui/scripts/mediaplayer.js +++ b/dashboard-ui/scripts/mediaplayer.js @@ -94,7 +94,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) { diff --git a/dashboard-ui/scripts/site.js b/dashboard-ui/scripts/site.js index 8043391597..7d8744bea6 100644 --- a/dashboard-ui/scripts/site.js +++ b/dashboard-ui/scripts/site.js @@ -804,9 +804,10 @@ var Dashboard = { MediaPlayer.seek(msg.Data.SeekPosition); } else if (msg.Data.Command === 'NextTrack') { - MediaPlayer.queuePlayNext(); + MediaPlayer.nextTrack(); } else if (msg.Data.Command === 'PreviousTrack') { + MediaPlayer.previousTrack(); } } },