diff options
Diffstat (limited to 'app/js/services.js')
-rw-r--r-- | app/js/services.js | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/app/js/services.js b/app/js/services.js index 9913856..d18e923 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -11,18 +11,18 @@ app.service('pathService', function() { }, computePlaylist: function(songList, line, duration) { //compute distances from the constrain path - console.log('length',line.length); - + console.log('length', line.length); + var threshold = 60; - angular.forEach(songList, function(song){ + angular.forEach(songList, function(song) { song.selected = false; }); - + var selection = []; - angular.forEach(line, function(point){ - angular.forEach(songList, function(song){ + angular.forEach(line, function(point) { + angular.forEach(songList, function(song) { var d = self.dist(song, point); - if(d < threshold && song.selected !== true){ + if (d < threshold && song.selected !== true) { selection.push(song); song.selected = true; } @@ -33,3 +33,18 @@ app.service('pathService', function() { }; return self; }); +app.service('musicPlayer', function() { + var self = { + musicTimer: null, + startSongWithDuration: function(id, duration) + { + $('#ytplayer').attr('src', 'https://www.youtube.com/embed/' + id + '?autoplay=1&modestbranding=1'); + self.musicTimer = setInterval(changeSong, duration * 1000); + }, + changeSong: function() + { + clearInterval(self.musicTimer); + } + }; + return self; +}); |