forked from asimpleenigma/MuseDB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMuseDB.java
167 lines (130 loc) · 5.08 KB
/
MuseDB.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
/*
*/
package musedb;
import javafx.application.Application;
import javafx.scene.*;
import javafx.scene.control.Button;
import javafx.scene.layout.*;
import javafx.stage.Stage;
//import java.beans.EventHandler;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
//import java.awt.event.ActionEvent;
//import java.nio.file.Files;
import java.io.File;
import javafx.stage.FileChooser;
import java.util.*;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.MenuBar;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
/**
*
* @author Lloyd Cloer
*/
public class MuseDB extends Application {
Player player;
VBox song_listing;
public static void main(String[] args) {
String s = "C:\\Users\\Lloyd Cloer\\Music\\Aesthetic Perfection\\Close To Human\\03 Architech.mp3";
File file = new File(s);
// Media media = new Media(s);
// System.out.print
// file = new File("file:/C:/Users/Lloyd%20Cloer/Music/AFI/AFI/01%20The%20Lost%20Souls.mp3");
// Player p = new Player();
// p.selectSong(file);
// p.play();
// FileCoordinator.copyFile(file, "C:\\Users\\Lloyd Cloer\\Music\\");
// System.out.println(FileCoordinator.extractMetadata(file));
// Media media = new Media(file.toURI().toString());
//MediaPlayer media_player = new MediaPlayer(media);
// System.out.println(media.getMetadata());
if (true){
MuseDB muse = new MuseDB();
muse.launch();
}
}
public void start(Stage stage) {
// *** Initialize Model Classes *** //
player = new Player();
// File file = new File("C:/Users/Lloyd%20Cloer/Music/AFI/AFI/01%20The%20Lost%20Souls.mp3");
// player.selectSong(file);
// player.play();
FileCoordinator fc = new FileCoordinator();
stage.setTitle("MuseDB");
BorderPane root = new BorderPane();
VBox control_panel = new VBox();
root.setLeft(control_panel);
song_listing = new VBox();
//root.setCenter(song_listing);
ScrollPane sp = new ScrollPane();
sp.setContent(song_listing);
root.setCenter(sp);
// **** File Import *** //
FileChooser file_chooser = new FileChooser();
// *** Menu Bar *** //
final Menu file_menu = new Menu("File");
MenuItem import_item = new MenuItem("Import");
import_item.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent t) {
List<File> list = file_chooser.showOpenMultipleDialog(stage);
fc.importFiles(list);
listSongs(list);
}
});
file_menu.getItems().add(import_item);
final Menu menu2 = new Menu("Options");
final Menu menu3 = new Menu("Help");
MenuBar menu_bar = new MenuBar();
menu_bar.getMenus().addAll(file_menu, menu2, menu3);
root.setTop(menu_bar);
//root
//******* Test Player *******/
Button play_button = new Button();
play_button.setText("Play");
play_button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent e) {
if (play_button.getText() == "Play"){
player.play();
play_button.setText("Pause");
}
else {
player.pause();
play_button.setText("Play");
}
}
});
control_panel.getChildren().add(play_button);
// Test playing music
//player.selectSong();
// player.play();
// Test moving files
String a1 = "C:\\Users\\Lloyd Cloer\\Documents\\Java Test\\Green Neuron.jpg";
String a2 = "C:\\Users\\Lloyd Cloer\\Documents\\Java Test\\the folder\\Green Neuron.jpg";
// FileCoordinator.moveFile(a2, a1);
stage.setScene(new Scene(root, 300, 250));
stage.show();
}
public void listSongs(List<File> list){
for (File f : list){
SongButton b = new SongButton();
b.setText(f.getName());
song_listing.getChildren().add(b);
}
}
public class SongButton extends Button{
public SongButton(){
setOnAction(
new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent e) {
File f = FileCoordinator.song_table.get(getText());
player.selectSong(f);
}
}
);
}
}
}