From 23b1c350b3677d06cc4312fb1a47292a7a4d03dc Mon Sep 17 00:00:00 2001 From: Tim Hobbs Date: Fri, 18 Apr 2014 00:56:38 -0700 Subject: [PATCH 1/3] Volume slider fix --- dashboard-ui/scripts/chromecast.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index af728673c6..d1dd7e6d93 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -984,6 +984,7 @@ }); $(castPlayer).on("/playback/update", function (e, data) { + self.positionTicks = data.positionTicks; self.runtimeTicks = data.runtimeTicks; @@ -1373,7 +1374,7 @@ canSeek: self.positionTicks < self.runtimeTicks, positionTicks: self.positionTicks, runtimeTicks: self.runtimeTicks, - volumeLevel: castPlayer.currentVolume + volumeLevel: castPlayer.currentVolume * 100 }; }; } From 7495ac44b0d649f9a57eb6703284b8fb41ff5703 Mon Sep 17 00:00:00 2001 From: Tim Hobbs Date: Fri, 18 Apr 2014 12:59:06 -0700 Subject: [PATCH 2/3] Cast updates * Store runtimeTicks in customData for persistence on reload * Enabled seeking * Fix for pause/mute state * Fix for slider enable/disable --- dashboard-ui/scripts/chromecast.js | 34 +++++++++++++++++---------- dashboard-ui/scripts/nowplayingbar.js | 5 ++-- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/dashboard-ui/scripts/chromecast.js b/dashboard-ui/scripts/chromecast.js index d1dd7e6d93..4b537b4c9b 100644 --- a/dashboard-ui/scripts/chromecast.js +++ b/dashboard-ui/scripts/chromecast.js @@ -273,7 +273,7 @@ var request = new chrome.cast.media.LoadRequest(castMediaInfo); request.autoplay = true; - request.currentTime = 0; + request.currentTime = startTimeTicks ? startTimeTicks / 10000000 : 0; this.castPlayerState = PLAYER_STATE.LOADING; this.session.loadMedia(request, @@ -289,7 +289,7 @@ console.log("chromecast new media session ID:" + mediaSession.mediaSessionId + ' (' + how + ')'); this.currentMediaSession = mediaSession; - this.currentMediaTime = this.session.media[0].currentTime; + this.currentMediaTime = mediaSession.currentTime; if (how == 'loadMedia') { this.castPlayerState = PLAYER_STATE.PLAYING; @@ -298,7 +298,7 @@ } if (how == 'activeSession') { - this.castPlayerState = this.session.media[0].playerState; + this.castPlayerState = mediaSession.playerState; } if (this.castPlayerState == PLAYER_STATE.PLAYING) { @@ -307,7 +307,7 @@ } this.currentMediaSession.addUpdateListener(this.onMediaStatusUpdate.bind(this)); - this.currentMediaDuration = this.currentMediaSession.media.duration; + this.currentMediaDuration = mediaSession.media.customData.runTimeTicks; }; /** @@ -474,7 +474,7 @@ CastPlayer.prototype.seekMedia = function (event) { var pos = parseInt(event); - var curr = parseInt(this.currentMediaTime + this.currentMediaDuration * pos); + var curr = pos / 10000000; if (this.castPlayerState != PLAYER_STATE.PLAYING && this.castPlayerState != PLAYER_STATE.PAUSED) { return; @@ -482,7 +482,7 @@ this.currentMediaTime = curr; console.log('Seeking ' + this.currentMediaSession.sessionId + ':' + - this.currentMediaSession.mediaSessionId + ' to ' + pos + "%"); + this.currentMediaSession.mediaSessionId + ' to ' + curr); var request = new chrome.cast.media.SeekRequest(); request.currentTime = this.currentMediaTime; this.currentMediaSession.seek(request, @@ -538,6 +538,14 @@ * Update progress bar based on timer */ CastPlayer.prototype.updateProgressBarByTimer = function () { + if (!this.currentMediaTime) { + this.currentMediaDuration = this.session.media[0].currentTime; + } + + if (!this.currentMediaDuration) { + this.currentMediaDuration = this.session.media[0].media.customData.runTimeTicks; + } + var pp = 0; if (this.currentMediaDuration > 0) { pp = Number(this.currentMediaTime / this.currentMediaDuration).toFixed(3); @@ -548,7 +556,7 @@ $(this).trigger("/playback/update", [{ positionTicks: this.currentMediaTime * 10000000, - runtimeTicks: this.currentMediaDuration * 10000000 + runtimeTicks: this.currentMediaDuration }]); } @@ -785,7 +793,8 @@ userId: Dashboard.getCurrentUserId(), deviceName: ApiClient.deviceName(), //deviceId: ApiClient.deviceId(), - startTimeTicks: startTimeTicks || 0 + startTimeTicks: startTimeTicks || 0, + runTimeTicks: item.RunTimeTicks }; } @@ -1287,9 +1296,8 @@ self.currentTimeElement.html(timeText); }; - self.changeStream = function (position) { - console.log("seek", position); - ////castPlayer.seekMedia(position); + self.changeStream = self.seek = function (position) { + castPlayer.seekMedia(position); }; self.removeFromPlaylist = function (i) { @@ -1374,7 +1382,9 @@ canSeek: self.positionTicks < self.runtimeTicks, positionTicks: self.positionTicks, runtimeTicks: self.runtimeTicks, - volumeLevel: castPlayer.currentVolume * 100 + volumeLevel: castPlayer.currentVolume * 100, + isPaused: self.isPaused, + isMuted: self.isMuted }; }; } diff --git a/dashboard-ui/scripts/nowplayingbar.js b/dashboard-ui/scripts/nowplayingbar.js index 27432acfce..730b3a4107 100644 --- a/dashboard-ui/scripts/nowplayingbar.js +++ b/dashboard-ui/scripts/nowplayingbar.js @@ -230,16 +230,17 @@ volumeSlider.slider('refresh'); if (!isPositionSliderActive) { + if (state.canSeek) { var pct = state.positionTicks / state.runtimeTicks; pct *= 100; - positionSlider.val(pct).prop('disabled', ''); + positionSlider.val(pct).slider("enable"); } else { - positionSlider.val(0).prop('disabled', 'disabled'); + positionSlider.val(0).slider("disable"); } positionSlider.slider('refresh'); From 04cd552aeb6be3905f93124f034b11cb27fbc8a1 Mon Sep 17 00:00:00 2001 From: Eric Reed Date: Sat, 19 Apr 2014 11:33:07 -0400 Subject: [PATCH 3/3] Standardize add buttons This has bothered me for a long time ;) --- dashboard-ui/library.html | 2 +- dashboard-ui/userprofiles.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dashboard-ui/library.html b/dashboard-ui/library.html index 6e281c9902..09761315f7 100644 --- a/dashboard-ui/library.html +++ b/dashboard-ui/library.html @@ -17,7 +17,7 @@

${ReferToMediaLibraryWiki}

- +

diff --git a/dashboard-ui/userprofiles.html b/dashboard-ui/userprofiles.html index 2897eaf519..7d70a355bc 100644 --- a/dashboard-ui/userprofiles.html +++ b/dashboard-ui/userprofiles.html @@ -16,7 +16,7 @@

-