-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSongHandler.java
More file actions
39 lines (39 loc) · 1.43 KB
/
SongHandler.java
File metadata and controls
39 lines (39 loc) · 1.43 KB
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
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.concurrent.TimeUnit;
public class SongHandler {
static Collections SongCollection = new Collections();
static ArrayList<String> PlaylistContents = new ArrayList<>();
static String songPath = "Songs/";
public static void initiateSongs(File[] files)
{
for (File filename : files) {
SongCollection.add(filename.getName());
}
}
void initiatePlaylist(String Playlist) throws IOException {
PlaylistContents.clear();
File readf = new File("Files/Playlist/"+Playlist+".txt");
if(!readf.exists()){
readf.createNewFile();
}
Scanner sc=new Scanner(readf);
while(sc.hasNextLine()){
String line = sc.nextLine();
line=line.trim();
PlaylistContents.add("Songs/"+line+".wav");
}
}
static void DisplaySongs(){SongCollection.printList();}
void Play() throws InterruptedException, IOException, UnsupportedAudioFileException, LineUnavailableException {
while(!Playlists.songQueue.isEmpty()){
Player.PlaySongs();
TimeUnit.SECONDS.sleep(1);
}
StartInterface.First();
}
}