diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/main/java/sbu/javafx/Launcher.java b/src/main/java/sbu/javafx/Launcher.java index c288d10..d0f017f 100644 --- a/src/main/java/sbu/javafx/Launcher.java +++ b/src/main/java/sbu/javafx/Launcher.java @@ -5,4 +5,6 @@ import javafx.application.Application; public class Launcher{ public static void main(String[] args) { // TODO: Launch the JavaFX application by calling Application.launch(Main.class) } + Application.launch(MusicApp.class, args); + } } diff --git a/src/main/java/sbu/javafx/MusicController.java b/src/main/java/sbu/javafx/MusicController.java index 5da27a9..38a6d59 100644 --- a/src/main/java/sbu/javafx/MusicController.java +++ b/src/main/java/sbu/javafx/MusicController.java @@ -1,31 +1,67 @@ package sbu.javafx; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; import javafx.fxml.FXML; -import javafx.event.ActionEvent; import javafx.scene.control.Label; -import javafx.scene.input.MouseEvent; -import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.util.ArrayList; public class MusicController { // TODO: Define your UI components using the @FXML annotation. + @FXML + private Label nowPlayingLabel; //TODO: Implement the logic to play a song. This method should update the UI to show which song is currently playing. + private ArrayList playlist = new ArrayList<>(); + private ObservableList observablePlaylist = FXCollections.observableArrayList(playlist); @FXML public void handlePlayAction() { //Update labels, change button icons, etc. } + @FXML public void playSong0() { nowPlayingLabel.setText("♪ Now Playing: Hello — Adele"); } + @FXML public void playSong1() { nowPlayingLabel.setText("♪ Now Playing: Someone Like You — Adele"); } + @FXML public void playSong2() { nowPlayingLabel.setText("♪ Now Playing: Rolling in the Deep — Adele"); } + @FXML public void playSong3() { nowPlayingLabel.setText("♪ Now Playing: Easy On Me — Adele"); } + @FXML public void playSong4() { nowPlayingLabel.setText("♪ Now Playing: Set Fire to the Rain — Adele"); } + @FXML public void playSong5() { nowPlayingLabel.setText("♪ Now Playing: Skyfall — Adele"); } + //TODO: Logic to add a specific song to the user's playlist. public void addToPlaylist(String songName) { //Add the song to a list or update a ListView. + if (!observablePlaylist.contains(songName)) { + observablePlaylist.add(songName); + } } - + @FXML public void addSong0() { addToPlaylist("Hello · Adele · 4:55"); } + @FXML public void addSong1() { addToPlaylist("Someone Like You · Adele · 4:45"); } + @FXML public void addSong2() { addToPlaylist("Rolling in the Deep · Adele · 3:48"); } + @FXML public void addSong3() { addToPlaylist("Easy On Me · Adele · 3:44"); } + @FXML public void addSong4() { addToPlaylist("Set Fire to the Rain · Adele · 4:01"); } + @FXML public void addSong5() { addToPlaylist("Skyfall · Adele · 4:46"); } // TODO:This method should open a new window or change the current scene to display the "Playlist" page. public void openPlaylistWindow() { //Create a new stage and show the playlist UI. } + @FXML + public void viewPlaylist() throws IOException { + FXMLLoader loader = new FXMLLoader(getClass().getResource("Playlist-view.fxml")); + Parent root = loader.load(); + + PlaylistController pc = loader.getController(); + pc.setPlaylist(observablePlaylist); + + Stage stage = (Stage) nowPlayingLabel.getScene().getWindow(); + stage.setScene(new Scene(root)); + } } diff --git a/src/main/java/sbu/javafx/PlaylistController.java b/src/main/java/sbu/javafx/PlaylistController.java new file mode 100644 index 0000000..f073d88 --- /dev/null +++ b/src/main/java/sbu/javafx/PlaylistController.java @@ -0,0 +1,29 @@ +package sbu.javafx; + +import javafx.collections.ObservableList; +import javafx.fxml.FXML; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.scene.control.ListView; +import javafx.stage.Stage; + +import java.io.IOException; + +public class PlaylistController { + + @FXML + private ListView playlistView; + + public void setPlaylist(ObservableList items) { + playlistView.setItems(items); + } + + @FXML + public void goBack() throws IOException { + FXMLLoader loader = new FXMLLoader(getClass().getResource("App-view.fxml")); + Parent root = loader.load(); + Stage stage = (Stage) playlistView.getScene().getWindow(); + stage.setScene(new Scene(root)); + } +} \ No newline at end of file diff --git a/src/main/java/sbu/javafx/icon.jpg b/src/main/java/sbu/javafx/icon.jpg new file mode 100644 index 0000000..dd0a2ae Binary files /dev/null and b/src/main/java/sbu/javafx/icon.jpg differ diff --git a/src/main/resources/sbu/javafx/App-view.fxml b/src/main/resources/sbu/javafx/App-view.fxml index 306c8d3..f72cb37 100644 --- a/src/main/resources/sbu/javafx/App-view.fxml +++ b/src/main/resources/sbu/javafx/App-view.fxml @@ -1,8 +1,112 @@ - - + + + - + - + + +