adding 'ambience mode', saving/restoring music options properly

This commit is contained in:
Egor Philippov 2015-11-17 13:44:49 -08:00
parent 94e26d607f
commit 1b42ef010a
5 changed files with 30 additions and 5 deletions

View file

@ -68,6 +68,7 @@ export default Em.Component.extend({
'<b>Sensitivity</b> - The sensitivity of the beat detector ( more sensitivity results in more registered beats )<br>' +
'<b>Flashing Transitions</b> - Quickly flash the lights on beat<br>' +
'<b>Colorloop Mode</b> - Slowly cycle the lights through all the colors while the music is playing<br>' +
'<b>Ambience Mode</b> - Periodically turn the lights on and off to create a cool looking ambience<br>' +
'<i><b>TIP</b>: Your sensitivity settings are saved per song as indicated by the red star icon in the top left corner. These settings they will be restored if you ever listen to the same song again.</i>',
position: 'top'
},

View file

@ -254,14 +254,20 @@ export default Em.Component.extend({
}.observes('strobeOn'),
strobeStep() {
var lastStrobeLight = (this.get('lastStrobeLight') + 1) % (this.get('activeLights').length + 1), self = this;
var lastStrobeLight = (this.get('lastStrobeLight') + 1) % (this.get('activeLights').length + 1),
turnOnOptions = {'on': true, 'transitiontime': 0, 'alert': 'select'};
// random light if in cololoop mode
if(this.get('colorloopMode')) {
turnOnOptions.hue = Math.floor(Math.random() * 65535);
}
Em.$.ajax(this.get('apiURL') + '/lights/' + lastStrobeLight + '/state', {
data: JSON.stringify({'on': true, 'transitiontime': 0, 'alert': 'select'}),
data: JSON.stringify(turnOnOptions),
contentType: 'application/json',
type: 'PUT'
});
Em.$.ajax(self.get('apiURL') + '/lights/' + lastStrobeLight + '/state', {
Em.$.ajax(this.get('apiURL') + '/lights/' + lastStrobeLight + '/state', {
data: JSON.stringify({'on': false, 'transitiontime': 0}),
contentType: 'application/json',
type: 'PUT'

View file

@ -502,6 +502,18 @@ export default Em.Component.extend(helperMixin, visualizerMixin, {
this.set('oldBeatPrefCache', newOldBeatPrefCache);
},
onAmbienceModeChange: function() {
if(this.get('ambienceMode') && this.get('playing')) {
this.set('ambienceModeHandle', setInterval(()=> {
//TODO
console.log('DOING AMBIENCE STUFF');
}, 2000));
} else if(this.get('ambienceModeHandle')) {
clearInterval(this.get('ambienceModeHandle'));
this.set('ambienceModeHandle', null);
}
}.observes('ambienceMode', 'playing'),
startUsingMic() {
navigator.getUserMedia(
{audio: true},
@ -695,7 +707,7 @@ export default Em.Component.extend(helperMixin, visualizerMixin, {
this.set('usingMicSupported', false);
}
['volume', 'shuffle', 'repeat', 'volumeMuted', 'threshold', 'playerBottomDisplayed', 'audioMode', 'songBeatPreferences', 'firstVisit', 'currentVisName', 'playQueue', 'playQueuePointer', 'micBoost', 'flashingTransitions'].forEach((item)=>{
['volume', 'shuffle', 'repeat', 'volumeMuted', 'threshold', 'playerBottomDisplayed', 'audioMode', 'songBeatPreferences', 'firstVisit', 'currentVisName', 'playQueue', 'playQueuePointer', 'micBoost', 'flashingTransitions', 'colorloopMode', 'ambienceMode'].forEach((item)=>{
if (!Em.isNone(storage.get('huegasm.' + item))) {
var itemVal = storage.get('huegasm.' + item);

View file

@ -70,11 +70,13 @@ export default Em.Mixin.create({
dragging: false,
draggingOverPlayListArea: false,
dragLeaveTimeoutHandle: null,
ambienceModeHandle: null,
audioStream: null,
dimmerOn: false,
isShowingAddSoundCloudModal: false,
colorloopMode: false,
ambienceMode: false,
flashingTransitions: false,
SC_CLIENT_ID: 'aeec0034f58ecd85c2bd1deaecc41594',
@ -260,7 +262,7 @@ export default Em.Mixin.create({
onOptionChange: function(self, option){
option = option.replace('.[]', '');
this.get('storage').set('huegasm.' + option, this.get(option));
}.observes('blinkingTransitions', 'playQueue.[]', 'playQueuePointer', 'colorloopMode'),
}.observes('flashingTransitions', 'playQueue.[]', 'playQueuePointer', 'colorloopMode', 'ambienceMode'),
onRepeatChange: function () {
var tooltipTxt = 'Repeat all', type = 'repeat';

View file

@ -169,6 +169,10 @@
<span data-toggle="tooltip" data-placement="bottom auto" data-title="Slowly cycle the lights through all the colors while the music is playing" class="bootstrapTooltip" {{action "hideTooltip" on="mouseLeave"}}>
{{#paper-checkbox checked=colorloopMode}}Colorloop Mode{{/paper-checkbox}}
</span>
<span data-toggle="tooltip" data-placement="bottom auto" data-title="Periodically turn the lights on and off to create a cool looking ambience" class="bootstrapTooltip" {{action "hideTooltip" on="mouseLeave"}}>
{{#paper-checkbox checked=ambienceMode}}Ambience Mode{{/paper-checkbox}}
</span>
</div>
</div>