From 1874c79cbe2483d4db40581375efd7e43553c59f Mon Sep 17 00:00:00 2001 From: lone-cloud Date: Tue, 29 Sep 2015 16:16:13 -0700 Subject: [PATCH] adding new beat options --- app/components/controls/music-control.js | 42 +++++++++++-------- app/components/mixins/music-control.js | 13 ++++++ app/styles/app.scss | 4 +- .../components/controls/music-control.hbs | 5 ++- 4 files changed, 43 insertions(+), 21 deletions(-) diff --git a/app/components/controls/music-control.js b/app/components/controls/music-control.js index 370f2c6..fe449c5 100644 --- a/app/components/controls/music-control.js +++ b/app/components/controls/music-control.js @@ -14,6 +14,8 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { }.observes('active'), actions: { + saveSongPreference: function() { + }, goToSong: function(index){ var dancer = this.get('dancer'), audio = new Audio(); audio.src = this.get('playQueue')[index].url; @@ -43,7 +45,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { this.changePlayerControl('threshold', beatOptions.threshold.defaultValue, true); this.changePlayerControl('decay', beatOptions.decay.defaultValue, true); this.changePlayerControl('frequency', beatOptions.frequency.defaultValue, true); - this.changePlayerControl('transitionTime', beatOptions.frequency.defaultValue, true); + this.changePlayerControl('transitionTime', beatOptions.transitionTime.defaultValue, true); }, playerAreaPlay: function(){ if(Em.isEmpty(Em.$('#playerControls:hover'))){ @@ -158,6 +160,9 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { speakerViewedChanged: function(value){ this.set('speakerViewed', value); }, + sequentialTransitionChanged: function(value){ + this.set('sequentialTransition', value); + }, clickSpeaker: function(){ this.simulateKick(1); }, @@ -251,33 +256,34 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { var activeLights = this.get('activeLights'), transitionTime = this.get('transitionTime') * 10, self = this, - briOff = function (i) { - Em.$.ajax(self.get('apiURL') + '/lights/' + i + '/state', { - data: JSON.stringify({'bri': 1, 'transitiontime': transitionTime}), + brightnessChange = function (light, brightness) { + Em.$.ajax(self.get('apiURL') + '/lights/' + light + '/state', { + data: JSON.stringify({'bri': brightness, 'transitiontime': transitionTime}), contentType: 'application/json', type: 'PUT' }); }; if(activeLights.length > 0){ - var lastLightBopIndex = this.get('lastLightBopIndex'), light = this.get('activeLights')[lastLightBopIndex]; - Em.$.ajax(self.get('apiURL') + '/lights/' + light + '/state', { - data: JSON.stringify({'bri': 254, 'transitiontime': 0}), - contentType: 'application/json', - type: 'PUT' - }); + var lastLightBopIndex = this.get('lastLightBopIndex'), + sequentialTransition = this.get('sequentialTransition'), + light; - setTimeout(briOff, 50, light); - lastLightBopIndex = (lastLightBopIndex+1)%activeLights.length; + if(sequentialTransition) { + light = activeLights[lastLightBopIndex]; + this.set('lastLightBopIndex', (lastLightBopIndex+1) % activeLights.length); + } else { + light = Math.floor(Math.random() * activeLights.length); + } - this.setProperties({ - paused: true, - lastLightBopIndex: lastLightBopIndex - }); + brightnessChange(light, 254); + setTimeout(brightnessChange, 50, light, 1); + + this.set('paused', true); setTimeout(function () { self.set('paused', false); - }, 150); + }, 100); } //work the music beat area @@ -324,7 +330,7 @@ export default Em.Component.extend(musicControlMixin, visualizerMixin, { kick: kick }); - ['volume', 'shuffle', 'repeat', 'volumeMuted', 'threshold', 'decay', 'frequency', 'speakerViewed'].forEach(function (item) { + ['volume', 'shuffle', 'repeat', 'volumeMuted', 'threshold', 'decay', 'frequency', 'speakerViewed', 'sequentialTransition'].forEach(function (item) { if (localStorage.getItem('huegasm.' + item)) { var itemVal = localStorage.getItem('huegasm.' + item); if (item === 'repeat' || item === 'volume' || item === 'decay' || item === 'threshold') { diff --git a/app/components/mixins/music-control.js b/app/components/mixins/music-control.js index 486954f..6f57829 100644 --- a/app/components/mixins/music-control.js +++ b/app/components/mixins/music-control.js @@ -117,6 +117,15 @@ export default Em.Mixin.create({ } }.property('speakerViewed'), + sequentialTransition: true, + sequentialTransitionLabel: function() { + if(this.get('sequentialTransition')){ + return 'Sequential'; + } else { + return 'Random'; + } + }.property('sequentialTransition'), + changePlayerControl: function(name, value, isOption){ if(isOption){ var options = {}; @@ -193,6 +202,10 @@ export default Em.Mixin.create({ this.get('beatHistory').clear(); }.observes('speakerViewed'), + onSequentialTransitionChange: function(){ + localStorage.setItem('huegasm.sequentialTransition', this.get('sequentialTransition')); + }.observes('sequentialTransition'), + onRepeatChange: function () { var tooltipTxt = 'Repeat all', type = 'repeat'; diff --git a/app/styles/app.scss b/app/styles/app.scss index fe56a5f..e14dbb4 100644 --- a/app/styles/app.scss +++ b/app/styles/app.scss @@ -55,7 +55,6 @@ md-switch[disabled=disabled], md-switch[disabled=disabled] .md-container, md-sli } .appSettingsItem.warn:hover { - text-transform: uppercase; background: rgba(255, 0, 0, 0.70); color: white; } @@ -725,6 +724,9 @@ md-switch.md-default-theme.md-checked .md-thumb { #playerButtonGroup { margin-top: 10px; + button { + box-shadow: 5px 0px 15px 5px rgba(0, 0, 0, 0.3); + } } #vertDivider { diff --git a/app/templates/components/controls/music-control.hbs b/app/templates/components/controls/music-control.hbs index 6d3af8d..d1aa4be 100644 --- a/app/templates/components/controls/music-control.hbs +++ b/app/templates/components/controls/music-control.hbs @@ -79,7 +79,7 @@ -
+
- {{switch-button}} + Transition type: {{#paper-switch checked=sequentialTransition}} {{sequentialTransitionLabel}} {{/paper-switch}}
{{#paper-button raised=true warn=true action="defaultControls"}}Default{{/paper-button}} + {{#paper-button raised=true action="saveSongPreference"}}Save Song Preference{{/paper-button}}