-
Notifications
You must be signed in to change notification settings - Fork 687
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
539 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/remote/jsonform/* | ||
*.min.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ speech/snowboydetect.pyc | |
.vscode | ||
keyfile.json | ||
smart-mirror.log | ||
jsonform |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
language: node_js | ||
node_js: | ||
- "6" | ||
- "10" | ||
|
||
before_install: | ||
- npm i -g npm | ||
|
||
# Cache node dependencies | ||
cache: | ||
directories: | ||
- node_modules | ||
- bower_components | ||
- bower_components |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
{ | ||
"schema": { | ||
"spotify": { | ||
"type": "object", | ||
"title": "Spotify Settings", | ||
"properties": { | ||
"timeout": { | ||
"type": "number", | ||
"title": "Default time in seconds to refresh spotify data", | ||
"default":10000 | ||
}, | ||
"default_device": { | ||
"type": "string", | ||
"title": "Default device name to change playback route on request", | ||
"default": "raspberry" | ||
}, | ||
"position": { | ||
"type": "string", | ||
"title": "Default status indicator position ('top' or 'bottom')", | ||
"default": "top" | ||
}, | ||
"creds": { | ||
"type": "object", | ||
"properties": { | ||
"clientID": { | ||
"default": "", | ||
"type": "string", | ||
"title": "OAuth 2.0 Client ID" | ||
}, | ||
"clientSecret": { | ||
"default": "", | ||
"type": "string", | ||
"title": "Client Secret" | ||
} | ||
} | ||
}, | ||
"authorization_uri": { | ||
"type": "object", | ||
"properties": { | ||
"scope": { | ||
"default": "user-read-private user-read-email streaming user-read-currently-playing user-modify-playback-state user-read-playback-state", | ||
"type": "string", | ||
"title": "Scope" | ||
}, | ||
"state": { | ||
"default": "3(#0/!~", | ||
"type": "string", | ||
"title": "State" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"form":[ | ||
{ | ||
"type":"fieldset", | ||
"title":"Spotify Settings", | ||
"expandable":true, | ||
"order":0, | ||
"items": [ | ||
"spotify.creds", | ||
"spotify.authorization_uri", | ||
{ | ||
"type": "help", | ||
"helpvalue": "<p><b>Ensure the spotify API settings allow redirects from 'http://localhost:4000/spotify_auth_callback'</b> then navigate to <a href='http://localhost:4000/authorize_spotify/' target='_blank'>Authorize</a> from your mirror browser.</p>" | ||
}, | ||
"spotify.timeout", | ||
"spotify.default_device", | ||
"spotify.position" | ||
] | ||
} | ||
], | ||
"value":{ | ||
"spotify":{ | ||
"timeout": 10000, | ||
"default_device": "raspberry", | ||
"position": "top", | ||
"authorization_uri": { | ||
"response_type": "code", | ||
"scope": "activity nutrition profile settings sleep social weight heartrate", | ||
"state": "3(#0/!~" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
function Spotify($scope, $http, SpotifyService, SpeechService, Focus, $interval) { | ||
|
||
SpotifyService.init(function () { | ||
refreshAuth(); | ||
addVoiceControl(); | ||
currentStateInfo(); | ||
$interval(refreshAuth, 60000 * 30); // minutes | ||
$interval(currentStateInfo, 1000 * config.spotify.timeout); // seconds | ||
}); | ||
|
||
var refreshAuth = function () { | ||
SpotifyService.refreshToken(); | ||
}; | ||
|
||
var currentStateInfo = function () { | ||
SpotifyService.currentState().then(function (response) { | ||
if (response) { | ||
$scope.spDevice = response.device.name || 'unknown'; | ||
$scope.spTrack = response.item.name; | ||
$scope.spArtist = response.item.artists[0].name; | ||
$scope.spPlaying = response.is_playing || false; | ||
$scope.spRepeat = response.repeat_state; | ||
$scope.spShuffle = response.shuffle_state; | ||
$scope.spThumb = response.item.album.images[0].url || 'http://i.imgur.com/8Jqd33w.jpg?1'; | ||
|
||
$scope.spActive = true; | ||
} else { | ||
$scope.spActive = false; | ||
} | ||
|
||
// console.debug("current state:", response, $scope); | ||
}); | ||
}; | ||
|
||
var addVoiceControl = function() { | ||
SpeechService.addCommand('spotify_play', function (query) { | ||
SpotifyService.playTrack(query); | ||
}); | ||
|
||
SpeechService.addCommand('spotify_pause', function () { | ||
SpotifyService.pause(); | ||
}); | ||
|
||
SpeechService.addCommand('spotify_forward', function () { | ||
SpotifyService.skipNext(); | ||
}); | ||
|
||
SpeechService.addCommand('spotify_back', function () { | ||
SpotifyService.skipBack(); | ||
}); | ||
|
||
SpeechService.addCommand('spotify_repeat', function () { | ||
var state = ($scope.spRepeat === 'track')? 'off': 'track'; | ||
SpotifyService.toggleRepeat(state); | ||
}); | ||
|
||
SpeechService.addCommand('spotify_shuffle', function () { | ||
var state = ($scope.spShuffle)? false: true; | ||
SpotifyService.toggleShuffle(state); | ||
}); | ||
|
||
SpeechService.addCommand('spotify_transfer', function (name) { | ||
SpotifyService.sendToDevice(name); | ||
}); | ||
}; | ||
} | ||
|
||
angular.module('SmartMirror') | ||
.controller('Spotify', Spotify); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<div ng-controller="Spotify" ng-show="spActive"> | ||
<div class="spotify-container animate-grow"> | ||
<img class="spotify-art" ng-src="{{spThumb}}" width="96" height="96"/> | ||
<span class="spotify-info"> | ||
<h2 class="spotify-track truncate" ng-bind="spTrack"></h2> | ||
<h3 class="spotify-artist truncate em-85" ng-bind="spArtist"></h3> | ||
<h3 class="spotify-device truncate em-85" ng-bind="spDevice"></h3> | ||
<span class="spotify-status-indicator"> | ||
<i ng-show="spPlaying" class="material-icons">play_circle_outline</i> | ||
<i ng-hide="spPlaying" class="material-icons">pause_circle_outline</i> | ||
<i ng-show="spShuffle" class="material-icons">shuffle</i> | ||
<i ng-show="spRepeat === 'track'" class="material-icons">repeat</i> | ||
</span> | ||
</span> | ||
</div> | ||
</div> |
Oops, something went wrong.