-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDriver.java
89 lines (80 loc) · 2.79 KB
/
Driver.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import com.echonest.api.v4.Artist;
import com.echonest.api.v4.EchoNestAPI;
import com.echonest.api.v4.EchoNestException;
import com.echonest.api.v4.Song;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import javazoom.jl.decoder.JavaLayerException;
import javazoom.jl.player.Player;
public class Driver {
@SuppressWarnings("resource")
public static void main(String[] args) throws EchoNestException {
Scanner sc = new Scanner(System.in);
String s = sc.nextLine();
String API_KEY = "SHCVOVEYFZ3D5XVVJ";
EchoNestAPI echoNest = new EchoNestAPI(API_KEY);
int x = 0;
List<Artist> hotArtists = echoNest.topHotArtists(x, 1000);
List<Song> songList = new ArrayList<Song>();
boolean flag = true;
for(int i = 0; i < hotArtists.size(); i++){
if(hotArtists.get(i).getName().equals(s)){
flag = true;
songList = hotArtists.get(i).getSongs();
break;
}
else{
flag = false;
}
}
if(flag == false){
System.out.println("We couldnt find your artist.");
System.exit(0);
}
String songInput = sc.nextLine();
String placeHolder = "SOSIFOJ14F33E91E6B";
Song currentSong = new Song(echoNest,placeHolder);
for(int i = 0; i < songList.size(); i++){
if(songList.get(i).getTitle().equals(songInput)){
flag = true;
currentSong = songList.get(i);
break;
}
else{
flag = false;
}
}
if(flag == false){
System.out.println("We couldnt find your song.");
System.exit(0);
}
try {
FileInputStream fis= new FileInputStream("/Users/Swellio/Downloads/Hotline Bling.mp3");
if(currentSong.getTitle().equals("Work")){
fis= new FileInputStream("/Users/Swellio/Downloads/Rihanna - Work ft. Drake (lyrics).mp3");
}
try {
Player playMP3 = new Player(fis);
playMP3.play();
} catch (JavaLayerException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
List<DanceMoves> danceMoves = new ArrayList<DanceMoves>();
DanceMoves move1 = new DanceMoves(12,135,"Hotline Bling");
DanceMoves move2 = new DanceMoves(12,95,"Work");
danceMoves.add(move1);
danceMoves.add(move2);
for(int i = 0; i < danceMoves.size(); i++){
if(Math.abs((danceMoves.get(i).getKey() - currentSong.getKey())) <= 5 && Math.abs((danceMoves.get(i).getTempo() - currentSong.getTempo())) <= 5){
}
}
}
}